🛠️DevTools

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 indentation
2const 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);
5
6// Output:
7// {
8// "database": {
9// "host": "localhost",
10// "port": 5432,
11// "name": "mydb"
12// },
13// "cache": {
14// "enabled": true,
15// "ttl": 3600
16// },
17// "logging": {
18// "level": "info",
19// "format": "json"
20// }
21// }

More JSON Examples

Related JSON Tools

📚 Learn More