JSON Formatter and Beautifier

Paste JSON and it is pretty-printed as you type, with every number and escape kept exactly as you wrote it.

How to use

  1. Paste your JSON into the Input box.
  2. Pick 2 spaces, 4 spaces, Tab or Minify; the Output updates as you type.
  3. If the JSON is invalid, read the reason and the line and column under the output, fix it and the output reappears.
  4. Press Copy to copy the result, or Clear to start again.

Examples

InputOutput
{"user":{"id":12345678901234567890,"name":"Ana"},"roles":["admin","editor"]}{ "user": { "id": 12345678901234567890, "name": "Ana" }, "roles": [ "admin", "editor" ] }
{ "price": 1.0, "city": "S\u00e3o Paulo" }{"price":1.0,"city":"S\u00e3o Paulo"}
{"name": "Kobako", "tags": ["json", "tools"],}
Trailing comma: remove the comma after the last item (line 1, column 46)

About this tool

What pretty-printing changes

A formatter only changes the whitespace between tokens: one key or array item per line, indented by nesting depth, with a space after each colon. Minify does the opposite and removes all of that whitespace. Nothing else moves. Keys stay in their original order, strings keep their spaces and line-break escapes, and the data a program reads is identical before and after.

2 spaces, 4 spaces or tabs

Two spaces is the most common choice in web projects and keeps deep structures narrow. Four spaces matches many Python and Java style guides. Tabs let each reader choose the width in their own editor. Use Minify for request bodies, environment variables or anywhere size matters.

Big numbers and escapes are kept

Many formatters run your text through JavaScript's JSON.parse and print it again. JavaScript numbers are 64-bit floats, so integers above 2^53 (9,007,199,254,740,992) can't all be represented: 12345678901234567890 comes back as 12345678901234567000, which silently corrupts database IDs and order numbers. The same round trip turns 1.0 into 1, decodes \u00e9 into é and drops all but the last of any duplicate keys.

This tool reads the text token by token instead, so numbers, escapes and duplicate keys come out exactly as they went in. RFC 8259 says names in an object should be unique and that numbers beyond 2^53 may not be read the same way by every program, so the formatter shows them as they are rather than deciding for you.

Common errors and their fix

  • Trailing comma: delete the comma after the last item in an object or array.
  • Missing comma: add a comma between two values or key/value pairs.
  • Missing colon: put : between the key and its value.
  • Single quotes: use double quotes for keys and strings.
  • Unquoted key: wrap the key in double quotes, "id" not id.
  • Comment: remove // and /* */; JSON has no comments.
  • Invalid escape: only \" \\ \/ \b \f \n \r \t and \uXXXX are allowed.
  • Line break or tab inside a string: write it as \n or \t.
  • Invalid number: no leading zeros (07), no 1. or .5, no NaN or Infinity.
  • Extra text after the JSON: a document holds one value; wrap several in an array.
  • Unexpected end: a bracket, brace or quote is not closed.

JSON is not a JavaScript object

A JavaScript object literal accepts single quotes, unquoted keys, trailing commas, comments and undefined. JSON accepts none of them. If you copied an object from source code, the error message points to the first place that needs changing.

Privacy

Formatting runs entirely in your browser. Nothing you paste is uploaded or stored, so API responses with tokens or personal data stay on your device.

Frequently asked questions

Does formatting change my data?

No. Only whitespace between tokens changes. Keys keep their order, and numbers, strings and escapes stay exactly as written.

Why do other formatters change 12345678901234567890?

Tools built on JavaScript's JSON.parse store numbers as 64-bit floats, which cannot hold every integer above 2^53, so 12345678901234567890 becomes 12345678901234567000. This formatter keeps the digits as written.

Are duplicate keys removed?

No. Duplicate keys are kept in place. Many programs keep only the last one when they read the file, so check whether duplicates are intended.

Why is my JSON invalid when it works in JavaScript?

JavaScript object literals allow single quotes, unquoted keys, trailing commas and comments. JSON allows none of these; the error message names the first problem and its line and column.

Is my JSON uploaded?

No. Formatting happens in your browser and nothing you paste is sent to a server.