Format Config JSON
Configuration files are much easier to read and edit when properly formatted with indentation.
Indent:
Switch tool:
Try:
Valid JSON
138 characters
Click nodes to toggle
{ "database": { "host": "localhost", "port": 5432, "name": "mydb" }, "cache": { "enabled": true, "ttl": 3600 }, "logging": { "level": "info", "format": "json" }}How it works
- Paste your JSON — it validates and formats automatically
- Invalid JSON shows error details with line/column position
- Choose 2 or 4 space indentation
- Copy or download the formatted result
Code Examples
Here's how to achieve this in different programming languages:
1// Format JSON with 2-space indentation2const input = `{"database":{"host":"localhost","port":5432,"name":"mydb"},"cache":{"enabled":true,"ttl":3600},"logging":{"level":"info","format":"json"}}`;3const formatted = JSON.stringify(JSON.parse(input), null, 2);4console.log(formatted);56// Output:7// {8// "database": {9// "host": "localhost",10// "port": 5432,11// "name": "mydb"12// },13// "cache": {14// "enabled": true,15// "ttl": 360016// },17// "logging": {18// "level": "info",19// "format": "json"20// }21// }
More JSON Examples
Format API Response
Format a typical REST API response with nested objects and arrays.
Format package.json
Format a Node.js package.json configuration file.
Format Nested JSON
Format complex deeply nested JSON structures with multiple levels.
Format GraphQL Response
Format GraphQL API response data with complex structures.