Skip to content

JSON Formatter & Validator

Beautify, minify and validate JSON with error line numbers. Runs in your browser.

Loading tool…

About this json formatter & validator

This JSON formatter turns a dense block of JSON into clean, indented text you can read, or squeezes it into one compact line. It also checks that the JSON is valid. When it is not, you get a plain-English message with the exact line and column, a snippet of the broken line with a caret under the problem, and a button that jumps to that spot in your input.

It is built for developers, testers and anyone who copies JSON out of an API response, a log file or a config. Paste the text, and the formatted result appears as you type. Choose 2 spaces, 4 spaces or tabs, sort keys alphabetically if you want stable diffs, then copy the result or download it as a .json file.

Your JSON never leaves your browser. There is no save button that creates a public link, and nothing is uploaded. That matters because pasted JSON often holds API keys, tokens and customer data.

Features

  • Exact error location

    Errors show the line, the column and a short snippet with a caret. Columns count each character once, so an emoji earlier on the line counts as one position, not two or four.

  • Errors written for people

    Instead of a vague "Unexpected token", you see messages such as "Trailing comma before '}' is not allowed" or "Property names must be wrapped in double quotes". The wording is the same in every browser.

  • Big numbers stay exact

    Long IDs such as 9007199254740993 keep every digit. The tool formats the original text instead of converting numbers, and it warns you when a number would lose precision in JavaScript.

  • Format, minify and sort keys

    Pretty-print with 2 spaces, 4 spaces or tabs, or minify to the smallest valid form and see how much smaller it got. Sort keys A to Z at every level to compare two files more easily.

  • Duplicate keys and BOM detection

    Duplicate property names are kept and reported, since most parsers silently keep only the last one. A byte order mark at the start of a file is removed with a note.

  • Open large files

    Open a .json file from your device. Inputs up to about 1 MB update live. Larger ones format when you press Format or Ctrl+Enter, so typing stays smooth.

  • Copy and download

    Copy the result with one click or download it as a .json file. Stats show input size, output size, the number of values and the deepest nesting level.

How to use the json formatter & validator

  1. 1Paste JSON or open a .json file. It is checked as you type.
  2. 2Pick Format or Minify, an indent, and Sort keys if you want.
  3. 3Fix any error using its line and column or Go to error, then copy or download.

When to use it

  • Reading API responses

    Paste a one-line response from an API or a browser network tab and get an indented version you can scan in seconds.

  • Fixing a broken config file

    Find the missing comma or stray quote in a package.json, a settings file or an app manifest without reading every line.

  • Shrinking JSON before sending it

    Minify a payload or a fixture file to remove whitespace before you embed it in code or send it over the network.

  • Comparing two JSON files

    Format both files with sorted keys and the same indent, then compare them in any diff tool. Key order no longer creates noise.

  • Checking data with large IDs

    Confirm that 64-bit IDs from a database or a social media API survive formatting, and see a warning if your own code might round them.

Common JSON errors and how to fix them

JSON looks like JavaScript, but its rules are stricter. Most errors come from habits that are fine in code but not allowed in JSON. Here are the ones this tool sees most often, with the fix for each.

  • Trailing comma: [1, 2, 3,] or {"a": 1,} is invalid. Remove the comma before the closing bracket.
  • Single quotes: {'name': 'Ada'} is invalid. Use double quotes for both keys and strings.
  • Unquoted keys: {name: "Ada"} is invalid. Wrap every property name in double quotes.
  • Comments: // and /* */ are not part of JSON. Delete them, or keep notes in a separate field.
  • Special values: NaN, Infinity and undefined are not allowed. Use null, or store the value as a string.
  • Python values: True, False and None must be written as true, false and null.
  • Line breaks inside a string: a string cannot span lines. Replace the line break with \n.
  • Leading zeros: 007 is not a valid number. Write 7, or use the string "007".
  • Missing comma between items: two values side by side need a comma between them.

Why large numbers can change in other tools

JavaScript stores every number as a 64-bit floating point value. It can represent whole numbers exactly only up to 9,007,199,254,740,991. Above that, nearby numbers share the same stored value, so 9007199254740993 quietly becomes 9007199254740992.

Many online formatters parse your JSON into JavaScript objects and then print them again, so long IDs from databases or social networks can change without warning. This tool reads and prints the original number text, so the digits you paste are the digits you get back. When it spots a number that JavaScript would round, it tells you, because the code that consumes the JSON may still need to treat it as a string or a BigInt.

Formatted or minified: which one to use

Formatted JSON uses line breaks and indentation so people can read it. Use it in config files, documentation, code reviews and anywhere a person edits the file.

Minified JSON removes every space and line break that is not inside a string. It carries exactly the same data in fewer bytes, which suits network payloads, embedded data and storage. Most servers also compress responses, so the gain on the wire is smaller than the raw numbers suggest, but minifying still helps for large files and logs.

Why use Mavros

 MavrosTypical upload sites
Where your JSON goesStays in your browserOften sent to a server, sometimes saved behind a share link
Error detailsLine, column, snippet with caret and a plain-English messageThe browser's raw parser message or a character offset
Numbers above 2^53Kept digit for digit, with a warningOften rounded silently
Duplicate keysKept and reportedUsually dropped without notice
Sort keysBuilt in, at every nesting levelOften missing
Sign-up or ads in the wayNoneCommon

Tips

  • Press Ctrl+Enter (Cmd+Enter on a Mac) inside the input to format right away.
  • Use Go to error to put the cursor on the exact character that broke the parse.
  • Turn on Sort keys before comparing two versions of the same file in a diff tool.
  • Pick tab indentation if your project's editor settings use tabs, so your diffs stay clean.
  • If you see the big number warning, make sure the code that reads the file treats those values as strings or BigInt.
  • For very large files, use Open file instead of pasting. Browsers handle file reads more smoothly than huge pastes.

Questions

How do I format JSON online?

Paste your JSON into the input box. The formatted version appears on the right as you type. Choose the indent you want, then copy it or download it as a .json file.

Why does it say my JSON is invalid?

The most common causes are trailing commas, single quotes, unquoted property names, comments and values such as NaN or undefined. The error message names the problem and shows its line and column.

What do the line and column numbers mean?

Line is the line in your input, starting at 1. Column is the position on that line, counted in characters, starting at 1. Press Go to error to select that character in the input.

Is my JSON uploaded or saved anywhere?

No. Formatting and validation run in your browser. Nothing is uploaded, nothing is stored on a server, and there is no public share link.

Can JSON have comments or trailing commas?

No. Standard JSON allows neither. Formats such as JSON5 and JSONC allow them, but most JSON parsers reject them, so this tool reports them as errors.

What is the difference between formatting and minifying JSON?

Formatting adds line breaks and indentation to make JSON readable. Minifying removes all unneeded whitespace to make it as small as possible. The data is the same either way.

Does sorting keys change my data?

No. JSON objects are unordered by definition, so sorting keys changes only the order they are written in. Array order is never changed.

Why did a long number change in another tool but not here?

JavaScript can store whole numbers exactly only up to 9,007,199,254,740,991. Tools that convert JSON into JavaScript values round larger numbers. This tool keeps the original digits.

How large a file can it handle?

Several megabytes work fine on a typical computer. Inputs over about 1 MB format when you press Format or Ctrl+Enter instead of on every keystroke, and very long results are previewed in part but copied and downloaded in full.