Every JSON file you have ever broken probably failed the same way. Not with a wrong value or a misspelled key, but with one missing character: a closing brace or bracket that never made it into the file. The data can be perfect and the file still will not parse, because JSON is all-or-nothing: a parser reads the structure first, and until every opener has its closer, nothing in the file exists as far as your program is concerned.

The frustrating part is where the error points. This guide explains why, and gives a level-by-level method for finding the missing closer with the free JSON Formatter and Validator on Ovatly, which runs in your browser and uploads nothing.

Contents

  • Quick answer
  • Why the whole file fails over one character
  • Why the error points at the end of the file
  • Braces, brackets, and the order closers must appear in
  • How to find a missing bracket or brace, step by step
  • Worked example: one object, one missing brace
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

A missing } or ] makes the whole file invalid, and the parser usually reports the failure at the end of the text, where it ran out of input while still waiting for a closer. Do not start hunting at the reported position. Paste the file into the JSON Formatter and Validator, run Validate to confirm the failure, then work one level at a time: count its openers and closers, fix the imbalance, validate again. Once the file parses, format it with a 2 or 4 space indent: the indentation shows the real structure, and a level closing in the wrong place becomes visible at a glance.

Why the whole file fails over one character

JSON is a tree. An object holds values, and those values can be arrays or further objects, nested as deep as the data needs. The parser builds that tree as it reads and cannot hand your program a partial one. If an object never closes, everything after its opening brace is, structurally, still inside that object, including the end of the file. The parse fails as a whole, and none of the values are ever delivered.

This is why bracket errors feel so disproportionate: a typo in a value affects one field, but a missing closer affects the shape of the whole document.

Why the error points at the end of the file

When a parser meets an opening brace, it expects a closing brace later, and it cannot declare the closer missing at any particular point, because the very next character might be it. So it reads on until the text runs out, and only then knows the closer never came.

A missing comma, by contrast, is wrong at one exact spot, and the validator names and locates it as it happens. A missing closer has no such spot, and jumping to the reported line sends you to the one place the problem almost never is.

Some bracket errors do surface mid-file: if the wrong kind of closer appears, a ] where a } belongs, the parser reports an unexpected character near the actual mistake. Both signatures are solved by the same counting method.

Braces, brackets, and the order closers must appear in

Braces wrap objects: { "name": "Ovatly" }. Brackets wrap arrays: [1, 2, 3]. In a nested document the closers must mirror the openers in reverse, innermost first. This file's counts balance, and it is still invalid:

{ "items": [1, 2 } ]

There is one {, one [, one } and one ], but the } tries to close the array and the ] tries to close the object, and the parser rejects the first wrong closer it meets. So the check is never just how many; it is how many, of which kind, at each level.

How to find a missing bracket or brace, step by step

  1. Open the JSON Formatter and Validator and paste in the failing JSON.
  2. Run Validate only. This checks the text without changing it, and the error names the problem in plain words.
  3. Start at the outermost level and count only its openers and closers, ignoring everything nested inside: one top-level { needs exactly one matching }.
  4. Move one level in and repeat, because a file can balance in total and still be wrong at one level.
  5. Fix the imbalance and validate again. A parser stops at the first problem it cannot get past, so a second error may hide behind the first; expect to repeat the loop.
  6. Once validation passes, format with a 2 or 4 space indent and read the indentation: each closer should line up with its opener, and a block that closes at the wrong level shows up as a sudden shift.

Worked example: one object, one missing brace

Here is a small, valid object:

{"name":"Ovatly","tools":250,"free":true}

Now the same object with its closing brace lost during an edit:

{"name":"Ovatly","tools":250,"free":true

Paste that into the validator and it fails, with the report landing at the end of the text, after true: the give-up point, not the crime scene. Count the level: one {, zero }. The document is a single level, so the fix is simply to restore the brace. Validated and formatted, the file reads:

{
  "name": "Ovatly",
  "tools": 250,
  "free": true
}

The indentation confirms the count: one level, opened and closed. In a larger file the same loop applies per level: the count tells you which level is short a closer, and the formatted output proves the structure.

Limitations and honest tradeoffs

The validator names the problem and where parsing stopped, but it cannot know which closer you intended or where you meant it to go. That judgement is yours: adding a closer at the end of the file can make invalid JSON parse while quietly putting data at the wrong level. The count-then-format method prevents exactly that.

Bracket errors are not the only strict failures: the same validator rejects trailing commas, single-quoted strings, unquoted keys and comments, because it applies the strict JSON standard. If your error names one of those instead, fix what the error names; the bracket count will not help. Two smaller points: very large pastes may take a moment, and number precision follows JavaScript, so integers beyond 2^53 lose exactness when reformatted. Validate only avoids that, since it never rewrites the text.

Common mistakes

  • Hunting at the reported line. The error position is where the parser gave up, usually the end of the file. Count levels instead.
  • Closing the gap at the end of the file. It may parse, but data ends up at the wrong level. Find the level that is short and close it there.
  • Counting the whole file at once. Totals can balance while one level is wrong. Count per level, per kind.
  • Trying to format first. Formatting needs a successful parse, so it fails on exactly the files you need help with.
  • Fixing one error and stopping. Parsers report the first problem they cannot pass. Re-validate after every fix until the file comes back clean.

FAQs

Why does the error point at the end of the file when the missing brace is in the middle? The parser keeps reading, expecting the structure to close eventually. It only knows a closer is missing when the text runs out, so the position it reports is where it gave up, not where the gap is.

What is the difference between braces and brackets in JSON? Braces wrap objects: key and value pairs between . Brackets wrap arrays: a list of values between [ and ]. Every opener needs its matching closer, and closers must appear in the reverse order of their openers, innermost first.

Does Validate change my JSON while it checks it? No. Validate only checks the text without changing it. Formatting is the action that rewrites the text with indentation, and formatting can only happen once the JSON already parses, which is why the hunt always starts with validation.

Can the counts balance and the JSON still be wrong? Yes. If a bracket closes an object or a brace closes an array, the totals match but the nesting is broken, and the parser fails on the wrong closer as an unexpected character. Counting per level is what catches this.

Why does formatting fail on my file? Formatting works by parsing the JSON and printing it back with even indentation, so an unclosed structure gives it nothing to print. Fix the brackets until validation passes, then format: the indentation is also the best visual check that every level closes where you think it does.

Conclusion

A missing brace is a small error with a misleading error message. Ignore the reported position, count openers and closers one level at a time with the JSON Formatter and Validator, and let the formatted indentation confirm the structure once the file parses again. If the broken file is a config you are about to ship, our companion guide on validating a JSON config file before deploying covers the pre-deploy check. For more guides in this series, see our Data and JSON Tools guides.

References