Developer utility

JSON Formatter & Validator

Format, validate and minify JSON data directly in your browser.

JSON Formatter & Validator

Format, validate, minify and inspect JSON directly in your browser.

Runs in your browser
Indent:
5 lines • 70 chars

About the JSON Formatter & Validator

The ProTools Hub JSON Formatter turns messy, minified or hard-to-read JSON into clean, indented text, and tells you immediately if the data is invalid. Paste your JSON or upload a .json file, choose 2 spaces, 4 spaces or tabs, and click Format. You can also minify the data to shrink it for APIs and configuration files, or simply validate it without changing anything.

When there is an error, the tool shows the browser's message along with the line and column where parsing stopped, so you can fix problems quickly instead of hunting through thousands of characters. After a successful run, a summary shows the size, number of keys, nesting depth and a count of each data type in your JSON.

All processing happens in your browser. The text you paste is not uploaded by this tool, which makes it suitable for everyday development work. As a general rule, avoid pasting secrets such as passwords or private keys into any website.

How to Use

  1. 1Paste your JSON into the input box, upload a .json file, or click Load Sample to try an example.
  2. 2Choose the indentation (2 spaces, 4 spaces or tab) and tick Sort keys if you want alphabetical order.
  3. 3Click Format JSON to beautify, Minify to compress, or Validate to only check for errors.
  4. 4If there is an error, read the message and go to the reported line and column.
  5. 5Copy the result, download it as a .json file, or click Use as input to keep working on it.

Key Features

  • Format, minify and validate in one place
  • Error line and column to find mistakes fast
  • 2 spaces, 4 spaces or tab indentation
  • Optional alphabetical key sorting
  • Upload .json files and download the result
  • Insights: size, keys, depth and data-type counts
  • No sign-up, no limits, processed in your browser

What Is JSON?

JSON stands for JavaScript Object Notation. It is a lightweight text format for storing and exchanging data, and it is the most common format used by web APIs, configuration files and modern databases. It is easy for people to read and easy for programs to parse, and almost every programming language has built-in support for it.

A JSON document is built from just two structures: objects, which are collections of named values wrapped in curly braces, and arrays, which are ordered lists wrapped in square brackets. Values can be any of the six types below.

TypeExampleNotes
String"hello"Text in double quotes
Number42, 3.14, -7, 1e3Integers and decimals, no leading zeros
Booleantrue, falseLowercase only
NullnullRepresents an empty value
Object{"key": "value"}Unordered key-value pairs
Array[1, 2, 3]Ordered list of values

Common JSON Errors and How to Fix Them

Most invalid JSON comes from a small set of mistakes, many of which are legal in JavaScript but not in strict JSON. If the validator reports an error, check whether your data matches one of these cases.

Trailing comma

Invalid

{"a": 1, "b": 2,}

Remove the comma after the last item. JavaScript allows it, but JSON does not.

Single quotes

Invalid

{'name': 'Ali'}

JSON requires double quotes around keys and strings: {"name": "Ali"}.

Unquoted keys

Invalid

{name: "Ali"}

Every key must be a double-quoted string: {"name": "Ali"}.

Missing comma

Invalid

{"a": 1 "b": 2}

Separate every key-value pair (and array item) with a comma.

Comments

Invalid

{"a": 1 // note}

JSON has no comment syntax. Delete comments before parsing.

Invalid values

Invalid

{"a": undefined, "b": NaN}

undefined, NaN and Infinity are not valid JSON. Use null or a string such as "NaN".

Leading zeros

Invalid

{"zip": 01234}

Numbers cannot start with 0. Store codes with leading zeros as strings: "01234".

Unescaped characters

Invalid

{"path": "C:\new"}

Backslashes and quotes inside strings must be escaped: "C:\\new".

When Do You Need a JSON Formatter?

Debugging API responses

Raw API responses often arrive on a single line. Formatting them reveals the structure so you can find the field you need.

Editing configuration files

Validate package.json, tsconfig.json, app settings and other config files before deploying to avoid a broken build.

Reducing payload size

Minify JSON before sending it over the network or embedding it in a page to save bandwidth.

Comparing two files

Sort keys on both versions so a diff tool shows only real differences instead of ordering noise.

Learning and teaching

Students can paste examples, see the structure clearly, and learn what valid JSON looks like.

Data cleaning

Check exports from databases, spreadsheets and third-party tools before importing them somewhere else.

Best Practices for Working With JSON

  • Use consistent key names. Pick one style, such as camelCase or snake_case, and use it everywhere so your data is predictable.
  • Store numbers as numbers. Avoid wrapping numeric values in quotes unless they are identifiers such as phone numbers or postal codes with leading zeros.
  • Keep nesting shallow. Deeply nested structures are harder to read and slower to process. Flatten data where it makes sense.
  • Never put secrets in shared JSON. API keys and passwords do not belong in files you paste into websites or commit to public repositories.
  • Validate before you deploy. A single missing comma in a config file can stop an application from starting, so run a quick validation first.

Related tools: JSON-LD Schema Generator, Base64 Encoder & Decoder, Markdown to HTML.

Frequently Asked Questions

What does a JSON formatter do?

A JSON formatter (also called a beautifier or pretty printer) takes compact or messy JSON and rewrites it with consistent indentation and line breaks so people can read it. It also validates the data: if the JSON is broken, it tells you where the problem is.

Is my JSON data sent to a server?

No. Parsing and formatting run in your browser with JavaScript, so the text you paste is not uploaded by this tool. If you work with sensitive data, you can even disconnect from the internet after the page loads and the tool will keep working. Please note that the website itself uses analytics and advertising scripts, described in our privacy policy.

What is the difference between formatting and minifying?

Formatting adds whitespace to make JSON easy to read. Minifying removes every unnecessary space and line break to make the file as small as possible, which is useful for APIs, configuration files and network requests. Both produce data with exactly the same meaning.

How do I find the error in invalid JSON?

Click Format or Validate. If the JSON is invalid, the tool shows the error message and, when the browser provides it, the line and column where parsing failed. The problem is usually at or just before that position, such as a missing comma on the previous line.

Why does it say 'Unexpected token'?

The parser found a character it did not expect. The most common causes are a trailing comma, single quotes instead of double quotes, an unquoted key, a missing comma between items, or a comment. See the list of common JSON errors on this page for examples and fixes.

What does 'Sort keys' do?

It rearranges the keys of every object into alphabetical order. This makes two JSON files easier to compare and gives stable output for version control. Arrays keep their original order because order is meaningful in arrays.

Does this tool change my data?

Formatting and minifying keep your data the same. Two details to know: if a JSON object contains the same key twice, only the last value is kept (this is how JSON.parse works), and very large integers beyond JavaScript's safe range (about 9 quadrillion) can lose precision. If you rely on those, keep the original text.

Is there a size limit?

You can process up to about 5 MB of text. Very large files can make the page slow because everything runs on your device. For huge files, a command-line tool such as jq is a better choice.