JSON Formatter & Beautifier

Turn a JSON on one unreadable line into clean, indented text. Choose 2 spaces, 4 spaces or tabs, and sort the keys if you want.

Runs only in your browser.
Valid JSON
Your JSON
Formatted
Indent
1{
2 "store": "Northwind Coffee",
3 "currency": "EUR",
4 "open": true,
5 "products": [
6 {
7 "id": 101,
8 "name": "Espresso",
9 "price": 2.2,
10 "tags": [
11 "hot",
12 "classic"
13 ]
14 },
15 {
16 "id": 102,
17 "name": "Flat white",
18 "price": 3.4,
19 "tags": [
20 "hot",
21 "milk"
22 ]
23 },
24 {
25 "id": 103,
26 "name": "Cold brew",
27 "price": 3.9,
28 "tags": [
324 B · 1 line

Get a URL for this JSON

Fix the errors first: only valid JSON can be hosted.

How to use it

  1. Paste your JSON on the left, or drop a .json file on it.
  2. The formatted JSON appears on the right. Choose the indent, and turn on "Sort keys" to order every object alphabetically.
  3. Copy it, download it as a file, or click "Use as input" to keep working on it.
  4. If the JSON is invalid, the formatter shows the error and where it is, as the validator does.

Examples

What the formatter does with a few typical inputs.

An API response on one line

With 2 spaces, the indent most JavaScript projects use.

Input

{"id":7,"name":"Ada","roles":["admin","dev"],"team":{"id":3,"name":"Core"}}

Formatted

{
  "id": 7,
  "name": "Ada",
  "roles": [
    "admin",
    "dev"
  ],
  "team": {
    "id": 3,
    "name": "Core"
  }
}

Sorted keys

Every object in alphabetical order, at every level. Useful before comparing two files, or to keep a config file tidy.

Input

{"zone":"eu","name":"api","limits":{"rate":100,"burst":20}}

Formatted

{
  "limits": {
    "burst": 20,
    "rate": 100
  },
  "name": "api",
  "zone": "eu"
}

Numbers are kept as written

Many formatters run the JSON through JavaScript, which rounds large numbers and drops the .0 of 1.0. This one doesn't.

Input

{"orderId":12345678901234567890,"price":10.0,"ratio":1e-7}

Formatted

{
    "orderId": 12345678901234567890,
    "price": 10.0,
    "ratio": 1e-7
}

Need a URL for this JSON?

Host it on JSONhost: your app reads it with a GET request, and you edit it from the website, the API or an AI agent.

Every hosted file is also an API. Read it, or a single value of it, and replace or patch it from your code.

Read the API docs

Read the whole file

curl https://jsonhost.com/json/abc123

Read one value

curl https://jsonhost.com/json/abc123/products/0/price

Change one field (JSON Patch)

curl -X PATCH https://jsonhost.com/json/abc123 \
  -H "Authorization: YOUR_FILE_TOKEN" \
  -d '[{ "op": "replace", "path": "/open", "value": false }]'

Questions

What's the difference between formatting and validating JSON?

Validating checks that the JSON is correct. Formatting changes only how it looks: indents and line breaks, so people can read it. This formatter does both: it can only format valid JSON, and if yours isn't, it shows the error.

Should I use 2 spaces, 4 spaces or tabs?

It doesn't change the data, only the look. 2 spaces is the most common in JavaScript and web projects, 4 spaces in Python and Java, and tabs let everyone choose their own width. If your project has a style, use that.

Does formatting change my data?

No. Keys keep their order (unless you turn on "Sort keys"), and numbers stay exactly as written: 1.0 stays 1.0 and 12345678901234567890 keeps all its digits. Only spaces and line breaks between values change. Text inside strings keeps its meaning, but escapes like \u00e9 may be written as the character itself.

How do I format JSON from the command line or in my code?

With jq: jq . file.json. With Python: python -m json.tool file.json. In JavaScript: JSON.stringify(JSON.parse(text), null, 2), but that rounds large numbers. In VS Code: Shift+Alt+F (Shift+Option+F on a Mac).

Is my JSON sent to a server?

No. Formatting happens in your browser. Nothing is uploaded unless you click "Host this JSON".

Can I get a URL for the formatted JSON?

Yes. Click "Host this JSON" and JSONhost gives it a URL your app can read. The free plan hosts a file up to 5 KB for 3 hours, to try it.

More JSON tools

All JSON tools

Host your first JSON in the next minute.

Upload a file, get a URL, and go back to building the part of your product that people see.