Skip to content
StringNook
Menu

JSON formatter and validator

Paste JSON to pretty-print it, check it for errors with the exact line and column, minify it or browse it as a tree. Nothing is sent anywhere, so it is safe for API keys and private data.

Off: your text is gone when you close the page. It is never sent anywhere.

Also accepts comments, trailing commas, single or curly quotes and names without quotes, and fixes them in the result.

Show
Indent with
Paste JSON in the box to check and format it. Errors show the exact line and column, with a plain-English fix.

Checked and formatted in your browser: nothing is uploaded, so it’s safe for API keys and private data.

  • Your JSON stays on your device
  • Free, no sign-up
  • Works on phone and desktop

How to format and validate JSON

  1. 1

    Paste JSON into the box, press Open file, or drop a .json file on the box.

  2. 2

    Read the check: Valid JSON, or the line and column of the first error with a plain-English fix. Go to the error puts the cursor on it.

  3. 3

    Choose Formatted (2 spaces, 4 spaces or tabs), Minified, Tree or String, and sort the keys if you like.

  4. 4

    Copy the result, or download it as formatted.json.

Features

  • Errors you can fix

    The exact line and column with a caret under the problem, and messages that name it: a trailing comma, single quotes, a missing comma, a comment or a stray bracket.

  • Quick with big files

    Files of several megabytes are checked and formatted in a background worker, so the page stays responsive. The tree view loads large lists in pieces.

  • Numbers kept exactly

    Long IDs such as 12345678901234567890 are written back exactly as they were, instead of being rounded the way many formatters round them.

  • Nothing is uploaded

    Your JSON never leaves this browser, so it is safe to paste API responses, tokens, keys and customer data.

JSON syntax rules in brief

JSON (JavaScript Object Notation) is defined by RFC 8259, a short standard from the Internet Engineering Task Force. Almost every error comes from breaking one of these rules:

  • A value is an object { }, a list (array) [ ], a string, a number, or one of true, false and null, always in lowercase.
  • Strings and property names go in straight double quotes. Single quotes and curly quotes aren’t allowed.
  • Inside a string, a double quote, a backslash and control characters such as line breaks and tabs must be escaped: \", \\, \n, \t, or \u with four hex digits.
  • Commas go between items and between name-value pairs, never after the last one. A colon separates each name from its value.
  • Numbers are plain decimals: no leading zeros (except 0 itself), no plus sign, no hexadecimal, and no NaN or Infinity.
  • Spaces, tabs and line breaks between values are ignored. Comments are not part of JSON.
  • A document holds exactly one value, usually an object or a list. Names should be unique within an object; when one repeats, programs disagree about which value wins.
  • JSON shared between systems must be encoded as UTF-8, and shouldn’t start with a byte order mark.

Common errors and how to fix them

The messages below are the ones the checker above gives for each mistake, with the position it points to. Each browser words its own JSON errors differently and none suggests a fix, which is why this tool uses its own parser.

MistakeWhat the checker saysFix
Trailing comma
{"a": 1, "b": 2,}
There’s a comma after the last property in this object. (line 1, column 16)Delete the last comma.
Single quotes
{'name': 'Ada'}
Strings must be in double quotes ("), not single quotes ('). (line 1, column 2)Use double quotes.
Name without quotes
{name: "Ada"}
Property names must be in double quotes: write "name" instead of name. (line 1, column 2)Quote every name.
Missing comma
{"a": 1 "b": 2}
A comma is missing between two properties. (line 1, column 9)Add a comma between pairs.
Comment
{"a": 1 // total }
JSON doesn’t allow comments. (line 1, column 9)Remove the comment.
Python or JavaScript values
{"ok": True, "x": None}
JSON writes true and false in lowercase, not True. (line 1, column 8)Use true, false and null.
Leading zero
{"zip": 02134}
Numbers can’t start with a zero (unless it’s 0 itself, or 0.5 and so on). (line 1, column 9)Quote codes that keep their zeros: "02134".
Windows path
{"path": "C:\Users"}
\U isn’t a valid escape in JSON. (line 1, column 13)Double each backslash: C:\\Users.
Curly quotes
{“name”: “Ada”}
Curly quotes (“ ” or ‘ ’) aren’t allowed: JSON needs straight double quotes ("). (line 1, column 2)Retype them as straight quotes.
Two values
{"a": 1} {"b": 2}
A second value starts here, after the first one has ended. (line 1, column 10)Wrap them in [ ] with a comma.

Lenient mode fixes the first five, plus curly quotes and unusual spaces copied from web pages, and lists what it changed. The rest need a decision from you, such as whether 02134 is a number or a code.

Formatting or minifying?

Formatted JSON is for people: one value per line, nested levels indented by 2 spaces, 4 spaces or a tab. Minified JSON is for machines: every space outside the strings removed. A small order record takes 266 bytes formatted with 2 spaces and 163 bytes minified, 39% less, and the saving grows with deeper nesting. Web servers often compress responses anyway, so minifying matters most for files you store or embed. The data is identical either way, and you can switch back and forth without losing anything.

The tree view is the quickest way to find your way around a long API response: open and close each level, see the type and size of every object and list, and copy the path to a value, such as items[1].sku, for use in code or a spreadsheet formula.

Big numbers and precision

JSON itself puts no limit on numbers, but RFC 8259 warns that whole numbers are only reliably exchanged between -9,007,199,254,740,991 and 9,007,199,254,740,991 (253 − 1), the range a 64-bit floating-point number holds exactly. Most formatters read your JSON into JavaScript numbers and write it back, so a long ID such as 12345678901234567890 comes out as 12345678901234567000. This one formats from its own parse of your text and writes {"id":12345678901234567890}, digit for digit, and it warns you when a number would be rounded by other programs. If you control the data, send long IDs as strings.

To see what changed between two versions of a file, paste both into text compare, after sorting the keys here so that the order doesn’t show up as a difference. The binary translator turns text into hex or binary bytes, and the case converter switches names between camelCase and snake_case.

Frequently asked questions

Is it safe to paste API keys or private data here?

Yes. The JSON is checked and formatted by code running in your browser, and nothing is sent to a server. It isn’t put in the page address or saved either, unless you turn on “Keep my text in this browser”, which stores it on your own device only.

What is the difference between formatting and minifying JSON?

Formatting (also called beautifying or pretty-printing) puts each value on its own line and indents nested objects and lists, so people can read it. Minifying removes every space and line break that isn’t inside a string, so the file is as small as possible for sending or storing. Both hold exactly the same data.

Why is the error reported on a line that looks fine?

The checker reports the spot where the JSON stopped making sense, which is sometimes just after the real mistake. A missing comma at the end of one line is noticed at the start of the next value, and a missing closing quote shows up at the end of the line. Read the message and look at the line above too.

Does JSON allow comments or trailing commas?

No. Standard JSON (RFC 8259) has no comments and no comma after the last item. Some tools accept them in their own config files (JSON with comments, or JSON5), and lenient mode here accepts them too, along with single quotes and unquoted names, then gives you standard JSON with the comments removed.

Why do some programs change my large numbers?

JavaScript and many other languages read JSON numbers as 64-bit floating-point values, which hold whole numbers exactly only up to 9,007,199,254,740,991. Bigger IDs are rounded to the nearest value they can hold. This formatter keeps every number exactly as written and warns you when one is too big; to be safe, send long IDs as strings.

What does “Sort keys A to Z” do?

It puts the properties of every object, at every level, in alphabetical order, ignoring upper and lower case and putting numbers in order (item2 before item10). Lists keep their order, because the order of a list is part of its meaning. Sorting makes two versions of the same data easier to compare.

How large a file can it handle?

Files up to 20 MB open. A file of a few megabytes is usually checked and formatted in under a second; very large files take a little longer, and the page stays usable meanwhile. The tree view shows the first 200 items of each list with a button to load more.

More free tools