Skip to content
TextBench Lab

JSON Formatter & Validator

Beautify, minify and validate JSON in your browser. Invalid JSON shows the line and column of the problem. Your data stays on your device and is never uploaded.

Status
Not checked
Size before
-
Size after
-
Top level
-

How to use the json formatter & validator

  1. Paste your JSON

    Put the JSON in the input box, from an API response, a config file or a log.

  2. Choose indent and key order

    Pick 2 spaces, 4 spaces or a tab, and tick Sort keys if you want keys in alphabetical order.

  3. Click Format, Minify or Validate

    Format makes it easy to read, Minify makes it compact, and Validate only checks it.

  4. Fix errors or copy the result

    If the JSON is invalid, the message shows the line, column and the text near the problem. Otherwise press Copy.

Features

  • Clear error messages

    See the line and column of the first problem, the line itself, and a hint for common mistakes.

  • Numbers stay as written

    Long numbers, 1.0 and 1e3 are not rewritten, and the key order is kept unless you sort.

  • Size and structure

    See the size before and after, and how many keys or items are at the top level.

  • Private

    Parsing happens in your browser. No data is sent or stored, and nothing is evaluated as code.

What JSON is and why it needs formatting

JSON stands for JavaScript Object Notation. It is a plain text format for data, used by web services, apps and configuration files. A JSON document is built from objects (pairs of a key and a value inside curly braces), arrays (lists inside square brackets), strings, numbers, true, false and null.

Computers do not care how JSON looks, so it often arrives as one long line with no spaces. That is hard for a person to read. A formatter adds line breaks and indentation so the structure is visible. A validator tells you whether the text follows the rules at all. This page does both, and it can also minify, which removes the extra spaces again.

Format, minify and validate

Format rewrites the JSON with one item per line and the indentation you choose: 2 spaces, 4 spaces or a tab. Empty objects and arrays stay on one line as and [].

Minify removes every space and line break that is not inside a string. The result is the shortest form of the same data, which is handy for sending it in a request or storing it in a small field.

Validate only checks the text and shows the statistics. It does not change anything.

None of these actions changes your data. Numbers are copied exactly as you wrote them, so a long number such as 12345678901234567890 is not rounded, 1.0 stays 1.0, and the order of keys stays the same. Text inside strings is not touched either.

Sort keys

Tick Sort keys to put the keys of every object in alphabetical order. The tool compares keys by character code, so capital letters come before small letters, and numbers written as keys are compared as text. Arrays keep their order, because the order of items in a list usually has meaning. Sorting keys is useful when you want to compare two JSON files, or keep a configuration file tidy.

Very deep nesting is the only limit here. If the JSON is nested more than 1,000 levels deep, the tool still formats and minifies it, but it will not sort it, and says so.

Understanding error messages

When the JSON is not valid, the tool shows the line and column of the first problem, the text of that line with a marker under the spot, and a short hint when the mistake is a common one. The position is the place where the parser noticed the problem, which can be just after the real mistake. If a closing bracket is reported, look at the item before it.

Typical mistakes are:

  • A comma after the last item. JSON does not allow it, so remove the comma before the closing bracket.
  • Single quotes. Strings and keys must use double quotes.
  • Keys without quotes. Write "name", not name.
  • Comments. Standard JSON has no comments, so lines starting with // or # are errors.
  • A missing comma between two items, or a missing colon after a key.
  • A missing bracket or quote at the end, which the tool reports as the JSON ending too soon.
  • A line break inside a string. Write it as \n instead.

Different browsers describe problems in different words, and some give no position at all. When that happens, this tool finds the first problem itself, so you still get a line and column.

The statistics

After you click a button you see four facts. Status says whether the JSON is valid. Size before and Size after are measured in bytes, so a character such as é counts as two and an emoji as four, which is how the text is stored in a file. Top level tells you what the JSON contains at its outermost level, for example an object with 5 keys or an array with 120 items. If an object repeats a key, the count includes it once, since that is how a parser reads it.

Size limit

You can paste up to 500,000 characters. JSON takes more work to check and print than plain text, so this limit is lower than the one for the other text tools. If you paste more, the tool keeps the first 500,000 characters and shows a message. The work runs only when you click a button, so typing and pasting stay smooth, even with a large document. For very large files, split the data into parts.

Safety and privacy

The tool checks your text with the JSON parser built into your browser. It never runs your text as code, so a document that looks like a script cannot do anything here. Your JSON stays on your device. It is not uploaded, stored or tracked, and there is no sign-up. Like every page on this site, this one may show ads from third-party vendors once ads are switched on, and those vendors can use cookies. Read the privacy policy for details.

Tips

  • Format first, then read the structure. Most mistakes become obvious once each item has its own line.
  • Use the text case converter to change the case of key names, and the remove duplicate lines tool to clean a list you copied out of JSON.

Frequently asked questions

Is my JSON uploaded anywhere?

No. The JSON is checked and formatted in your browser. Nothing is sent to a server or saved, so it is gone when you close or refresh the page.

What is the difference between Format, Minify and Validate?

Format adds line breaks and indentation so people can read it. Minify removes all spaces and line breaks outside strings so the text is as short as possible. Validate only checks that the JSON is correct and shows the stats.

Why is my JSON invalid?

Common reasons are a comma after the last item, single quotes instead of double quotes, keys without quotes, comments, or a missing bracket. The error message shows the line and column of the first problem, which is often just after the real mistake.

Does Sort keys change my data?

It changes only the order of keys inside objects, from A to Z by character code. Arrays keep their order, and values are not changed.

What is the size limit?

You can paste up to 500,000 characters. JSON is more work to process than plain text, so the limit is lower than for the other tools here. If your JSON is larger, only the first part is kept and a message tells you.

Does it handle comments or trailing commas?

No. Standard JSON does not allow comments or trailing commas, so the tool reports them as errors and tells you where they are. Remove them and try again.