JSON Formatter

Format, validate and pretty-print JSON with clear error messages.

Developer Tools Free, no sign-up Runs in your browser

JSON Formatter tool

About the JSON Formatter

JSON Formatter takes JSON in any shape, checks that it is valid and prints it back with consistent indentation so you can read it. API responses and config files often arrive as one unbroken line; formatting them is the fastest way to see the structure and find the field you are looking for.

When JSON will not parse, the tool reports the problem in plain language along with the line and column where the parser gave up. Most invalid JSON comes down to a handful of mistakes: a trailing comma after the last item, single quotes instead of double quotes around keys, an unescaped quote inside a string, or a missing closing bracket. The error message points you at the spot rather than making you hunt.

Parsing uses the browser's built-in JSON parser. The tool never evaluates your input as code, so pasting JSON from an untrusted source is safe, and nothing is transmitted to a server.

How to use the JSON Formatter

  1. Paste your JSONDrop in an API response, a config file or any JSON fragment.
  2. Choose an indent sizeTwo spaces, four spaces or a tab, depending on your project's style.
  3. Press FormatValid JSON is reprinted with indentation. Invalid JSON produces an error naming the line and column.
  4. Copy or downloadTake the formatted JSON with the copy button, or save it as a .json file.

Features

  • Validate and pretty-print in one step
  • Choose two spaces, four spaces or tab indentation
  • Error messages that name the line and column
  • Minify back to a single line
  • Sort object keys alphabetically
  • Reports node count and nesting depth
  • Copy and download the result
  • Uses the native JSON parser, never eval

Who uses this tool

The json formatter is used by writers, developers, students, marketers and anyone else who needs the job done once without installing software. Common cases include:

  • Reading an API response that arrived as one long line
  • Checking that a config file is valid before deploying it
  • Finding the syntax error in JSON that a build tool rejected
  • Comparing two structures by formatting both the same way
  • Preparing readable JSON for documentation or a bug report

Frequently asked questions

Why does my JSON fail to parse when it looks fine?

The usual causes are a trailing comma after the final item in an object or array, single quotes instead of double quotes, unquoted keys, or a stray character copied from a rich text editor. The error message gives the line and column where parsing stopped, which is normally one character past the real mistake.

Is JSON with comments supported?

No. Comments are not part of the JSON specification, so a file containing them is not valid JSON and will be rejected. Strip the comments first if you are working with a format such as JSONC.

Does formatting change my data?

No. Only whitespace changes. Keys, values, types and array order stay exactly as they were, unless you choose the option to sort keys alphabetically.

Is my JSON sent anywhere?

No. The browser's own parser handles everything inside the page, so API keys and customer data in a payload never leave your device.

What is the largest file I can format?

Documents of several megabytes format without trouble on a normal machine. Very large files may take a moment and will use memory in the tab, but nothing is uploaded.

Why would I sort the keys?

Sorting keys gives two versions of the same object a consistent order, which makes them far easier to compare in a diff tool or by eye.

If the json formatter is not quite what you need, these other free tools solve closely related problems.

JSON Minifier

Strip whitespace from JSON and compare original and minified sizes.

Developer Tools Use tool

Base64 Encoder

Encode any text, including emoji and accents, to a Base64 string.

Encoding & Conversion Use tool

URL Encoder

Escape spaces, symbols and non-ASCII characters for use in URLs.

Encoding & Conversion Use tool

HTML Encoder & Decoder

Escape angle brackets and quotes to HTML entities, or decode them back.

Encoding & Conversion Use tool

Timestamp Converter

Translate between Unix time and human-readable dates in both directions.

Developer Tools Use tool