Skip to content

Online JSON editor and formatter

Paste JSON to format, check and fix it. Errors show the exact line and what to change. Nothing is uploaded.

Ln 1, Col 10 bytesUTF-8Saved in this browser
For other languages use the code editor. A table of records? The CSV editor opens the CSV you make here.
Type or paste JSON. It is checked as you type.

    Commands work on the whole document. Ctrl Z undoes them.

    Advertisement

    Last checked by the TextEditor.com team

    What JSON is

    JSON is a text format for data. It looks like the way JavaScript writes objects, which is where the name comes from. Douglas Crockford described the rules in 2001 and put them on json.org. Today two standards define it, RFC 8259 from 2017 and ECMA-404, and they agree with each other.

    The whole grammar fits on one page. A JSON text is one value. A value is an object, an array, a string, a number, true, false or null. Objects hold key and value pairs, arrays hold values in order. That is all, and it is why every language can read it.

    The grammar in one figure

    Click a type to see every value of that kind
    {
      "name": "Mia",
      "age": 34,
      "member": true,
      "nickname": null,
      "scores": [9.5, 8, 10],
      "address": { "city": "Oslo", "zip": "0150" }
    }
    Object
    { } with pairs of "key": value, separated by commas. Keys are strings. The order does not matter.
    Array
    [ ] with values separated by commas. The order matters. Values may be of different types.
    Key
    A string in double quotes, followed by a colon. Any text works, even with spaces.
    String
    Text in double quotes. Special characters use a backslash: \" \\ \n \t é. Single quotes are not allowed.
    Number
    Decimal digits, an optional minus sign, a decimal part and an exponent: -12, 3.14, 1e10. No leading zeros, no plus sign, no hex, no NaN or Infinity.
    Boolean
    true or false, in lowercase, without quotes.
    Null
    null means "no value". Not None, not nil, not undefined.

    The five most common errors

    Almost every "invalid JSON" message comes from one of five mistakes, and four of them are things that JavaScript allows but JSON does not. The validator above names the mistake and the line. The Repair button fixes all five and tells you what it changed.

    MistakeWrongRight
    Trailing comma{"a": 1,}{"a": 1}
    Single quotes{'a': 'x'}{"a": "x"}
    Unquoted key{a: 1}{"a": 1}
    Comment{"a": 1 // note}{"a": 1}
    Missing comma{"a": 1 "b": 2}{"a": 1, "b": 2}
    Try it: what the validator says
    Trailing comma: there is a comma before this }. Remove the last comma.

    JSON or a JavaScript object literal?

    They look alike, and that is the trap. A JavaScript object can be written in many ways. JSON allows exactly one. Since 2019 every valid JSON text is also valid JavaScript, but the reverse is far from true.

    FeatureJSONJavaScript object
    KeysAlways in double quotesBare names or any quotes
    StringsDouble quotes onlySingle, double or backticks
    Trailing commaNot allowedAllowed
    CommentsNot allowedAllowed
    ValuesObject, array, string, number, true, false, nullAlso undefined, functions, dates, NaN, regular expressions
    NumbersDecimal onlyAlso hex (0xFF), octal, binary, BigInt (12n)

    The Convert menu above turns JSON into a JavaScript object literal with bare keys, which is what you paste into a .js file. The other way, use Repair: it quotes the keys and swaps the quotes.

    Comments: JSON5 and JSONC

    JSON has no comments, by design. Crockford removed them because people used them to carry parsing directions. Two relaxed versions brought them back. JSONC is JSON plus // and /* */ comments, and often trailing commas. VS Code uses it for settings.json, and TypeScript accepts it in tsconfig.json. JSON5, from 2012, goes further: single quotes, unquoted keys, hex numbers, Infinity and multi line strings.

    Outside those tools, assume strict JSON. npm fails on a comment in package.json, and web APIs reject it. If a file with comments must become real JSON, paste it above and click Repair. It removes the comments and lists how many.

    Numbers and precision

    The JSON grammar puts no limit on a number. The programs that read it do. JavaScript stores every number as a 64 bit float, which holds whole numbers exactly only up to 253 minus 1, that is 9,007,199,254,740,991. One digit more and the last digits get rounded. Twitter ran into this with tweet IDs in 2010 and added an id_str field as a string. Python and Java keep big integers exact.

    Most online formatters run on JavaScript and quietly change such numbers when they format. This page keeps every number exactly as you wrote it, because it never turns it into a JavaScript number. Type a long number below to see what JavaScript would make of it.

    What JavaScript does with a big number

    JavaScript reads it as 9007199254740992. That is not the same number. Send it as a string: "9007199254740993".

    Where JSON is used

    Web APIs answer in JSON, and nearly every programming language has a JSON reader built in. Configuration files use it: package.json for npm, tsconfig.json, composer.json, the settings of VS Code. Browsers keep data in it through localStorage. Databases like MongoDB and CouchDB store documents as JSON or a binary twin of it. Log systems write one JSON object per line, a form called NDJSON. Jupyter notebooks are JSON files.

    When the data is a list of records, a table is easier to read. Convert it to CSV above and open it in the CSV editor or the table editor. For HTML, CSS or Python files use the code editor, which this page is built on.

    More tools for data

    Frequently asked questions

    Is my JSON uploaded to your server?

    No. The page runs in your browser. Your text is saved in this browser only, so you find it again when you come back on the same device.

    Why is my JSON invalid when it looks fine?

    The usual reasons: a comma after the last item, single quotes, a key without quotes, a comment, or a missing comma between two values. The message under the editor names the line. Click Repair to fix the common ones.

    Can I edit values in the tree view?

    Yes. Open the Tree tab and click a value. Type the new value and press Enter. Numbers, true, false and null are kept as such, anything else becomes a string. The code updates at once.

    How do I turn JSON into CSV or Excel?

    Pick "To CSV" in the Convert menu. It works when the JSON is an array of objects, with one row per object and one column per key. Download the file or open it in the CSV editor, which also saves Excel.

    Are comments allowed in JSON?

    Not in standard JSON. VS Code settings and tsconfig.json accept them, because those tools read JSONC. For an API or package.json, remove them. The Repair button does that.

    How do I decode a Base64 value inside my JSON?

    Copy the value into the encoder and decoder. It finds Base64, URL encoding and escapes on its own and decodes them in one click.

    • Text editorWrite and edit plain text in your browser.
    • HTML editorWrite in a visual editor and get clean HTML code.
    • ASCII tableAll 128 ASCII codes with decimal, hex, octal, binary and HTML values.
    • Text comparePaste two texts and see every changed line and word highlighted side by side.
    • Markdown tableType or paste cells, pick the alignment and copy a clean Markdown table.
    • Sort linesSort lines A to Z, by number or by length.

    ↑ ↓ to choose, Enter to open, Esc to close