Premium tools, free for everyone. Most run right in your browser.

OpenMultiURL

Developers

How to Validate JSON Online and Fix Syntax Errors

How to Validate JSON Online and Fix Syntax Errors title on a coloured card

A missing comma can leave you staring at an error beside a line that looks completely fine. My first move is to check the syntax before changing the data itself. When I validate JSON online, I want to know where parsing stopped, what probably caused it, and whether the corrected text still says what I meant. I built JSON Formatter and Validator for that kind of check, and I test my tools on a budget Android phone and a laptop.

What does an online JSON validator actually check?

I think of a JSON validator as a reader with strict rules. It checks whether your text can be parsed as JSON, rather than guessing what you intended. JSON is a text format for exchanging data, defined in RFC 8259. That standard is my reference when a JavaScript example and a JSON checker disagree.

I separate valid syntax from useful data

The text {"age":"twenty"} is valid JSON. But if your application expects age to be a number, the value is wrong for that application. A syntax checker cannot infer that requirement from the property name. I don't want a green result to send you chasing the wrong problem, so I keep syntax, schema, and application checks separate.

I use these checks at different stages, rather than treating them as interchangeable.
CheckWhat it answersWhat I check next
JSON syntaxCan a JSON parser read this text?Whether the structure matches the expected data
JSON SchemaDoes the data meet the supplied structure and constraints?Whether the receiving application has more rules
Application or API validationDoes this data meet this system's requirements?The specific rejection message and documented requirements

Formatting is another separate job. It makes nesting easier to read, but tidy indentation doesn't prove the values are correct. My JSON Formatter and Validator brings syntax checking and readable formatting into the same workflow. I still review the result before copying it into a request or configuration file.

How do I validate JSON online step by step?

I've tried these steps with JSON Formatter and Validator. I start with a complete, non-sensitive example rather than a fragment copied from the middle of a response. That keeps a missing opening brace from distracting me from the problem I actually want to investigate.

  1. I open JSON Formatter and Validator and paste the JSON into its input.
    • I include the complete value, including its opening and closing characters.
    • I leave out surrounding explanation, copied code fences, and unrelated error messages.
  2. I run the validation check and read the result before editing anything.
  3. If parsing fails, I inspect the reported location and the text immediately before it.
  4. I fix the first clear mistake, then run the check again.
  5. Once parsing succeeds, I review the formatted structure and compare the values with the original.
  6. Before using the result, I check the receiving system's required fields and data types.

I use a small example to isolate the mistake

For a practice check, I can paste {"name":"Alex" "active":true}. The two properties have no comma between them. The corrected text is {"name":"Alex","active":true}. I change only the separator, then validate again. That small example makes the repair clear without changing a name, removing a field, or guessing at a value.

Tip from me: I keep an untouched copy of the original text before editing. If a repair changes the meaning, I can compare the two instead of trying to remember what was there.

What counts as valid JSON, including a single value?

I don't assume every JSON document must start with a curly brace. An object is common, but RFC 8259 also allows an array, a string, a number, or one of the literals true, false, and null as the complete JSON text. Your receiving application may accept fewer shapes than the JSON format itself allows.

  • I can use an object such as {"ready":true} or an array such as ["red","blue"].
  • I can use a complete string such as "ready", including its double quotes.
  • I can use a number such as 0, or a lowercase literal such as false or null.
  • I cannot treat empty input or a loose property such as "ready":true as a complete JSON value.

I check number rules and duplicate names separately

JSON numbers cannot have leading zeros, except for zero itself. I would change a numeric value written as 01 only after checking what it means. If it represents an identifier whose leading zero matters, a quoted string may be the intended type. Infinity and NaN are not JSON numbers either.

I also avoid duplicate property names. The standard says names should be unique, and implementations can handle duplicates differently. So I wouldn't call {"status":"new","status":"done"} reliably usable just because a parser accepts it. I resolve the conflicting fields deliberately. Large numbers need similar care: valid syntax alone doesn't guarantee that every parser preserves the same numeric precision.

Which JSON syntax mistakes should I fix first?

I start with punctuation and quotes because they're easy to inspect without changing the data. A JSON object uses double-quoted names, a colon between each name and value, and commas between members. Arrays use commas between values too. Neither structure allows a comma after its final item.

These are the mistakes I look for before making broader edits.
ProblemWhat I look forMy repair
Missing commaTwo properties or array values placed togetherInsert the missing separator
Trailing commaA comma immediately before a closing brace or bracketRemove that final comma
Single quotesA name or string surrounded by apostrophesUse double quotes with the right escaping
Missing colonA property name followed directly by its valueInsert a colon between them
Mismatched bracketsAn object closed as an array, or an unfinished structureMatch each opening character to the right closing character
Wrong literal caseTrue, False, or None used as a literalUse true, false, or null where that is the intended value

I inspect escaping inside strings

Quotes inside a string need escaping so the parser doesn't mistake them for the end of the value. Backslashes and control characters also need the right escaping. For example, a literal line break inside a quoted string is different from an escaped newline. I check the actual text, not just how the surrounding editor makes it look.

I don't recommend replacing every apostrophe or backslash across a document. An apostrophe can be ordinary content inside a double-quoted string. A backslash may already be correctly escaped. A broad replacement can turn one visible syntax error into a less visible data error. I prefer a small repair followed by another validation check.

Why does the JSON error point to the wrong line?

I read an error location as the place where parsing became impossible, not necessarily where the mistake began. If a comma is missing between two properties, the parser may stop at the second property's name. That name can be perfectly written. The missing separator before it is the real problem.

  1. I inspect the reported character or line for an obvious misplaced symbol.
  2. I look immediately before it for a missing comma, colon, or closing quote.
  3. I trace the surrounding object or array back to its opening character.
  4. If parsing stops at the end, I check for an unfinished string or unclosed structure earlier in the text.
  5. I make one justified repair and validate again before following another error.

Parser messages vary, so I don't expect every tool to describe the same fault with identical words or positions. I focus on the surrounding structure instead. If the original text is hard to discuss, Add Line Numbers can give me a numbered reference copy. I keep those added numbers out of the JSON input.

Tip from me: I don't delete a whole troublesome section just to get a valid result. I may isolate a smaller copy for diagnosis, but I put the intended data back and validate the complete document before using it.

Once the syntax is valid, formatting helps me inspect which fields belong inside which object. It is much easier to spot a misplaced closing brace with readable nesting. But I still compare the structure with what I intended, because a brace in the wrong place can sometimes leave syntactically valid JSON.

Is JavaScript object syntax the same as JSON?

I treat JavaScript object examples as something to check, not something to paste blindly into a strict JSON field. The example {name:'Alex'} may look familiar from JavaScript, but it isn't strict JSON. The property name is unquoted and the string uses single quotes. The JSON version is {"name":"Alex"}.

I check which format the receiving system expects

Strict JSON doesn't allow comments or trailing commas. A configuration parser using JSONC or JSON5 may accept extensions, but that doesn't make those formats interchangeable with JSON. I check the receiving system's documentation before editing a configuration file. Something accepted there may still fail when copied into an API request body.

  • I quote every object member name with double quotes.
  • I remove comments only when the target really requires strict JSON.
  • I remove trailing commas from strict JSON objects and arrays.
  • I use a JSON parser rather than an eval-like function to check JSON text.

The last point is a security boundary, not a style preference. RFC 8259 warns about the risk of eval-like parsing. I also use MDN's trailing comma reference when explaining why a comma works in a JavaScript example but fails in JSON. Similar-looking syntax is not a promise of identical rules.

How do I check JSON Schema and API requirements?

After syntax passes, I ask a different question: does this document contain the data the receiver requires? JSON Schema describes constraints on structure and values. It can check required properties and expected data types, among other rules. The JSON Schema documentation explains this separate validation layer.

For example, {"name":"Alex"} can pass a syntax check while failing a schema that also requires an age property. And {"age":"20"} contains a string, not a number. I don't change that type simply to satisfy a guess. I check the schema or API documentation to find out what the field actually expects.

  1. I validate the JSON syntax before investigating schema failures.
  2. I obtain the applicable schema from the receiving system's documentation or project files.
  3. I use a JSON Schema validator that supports the schema's declared version.
  4. I review missing fields, wrong types, and other reported constraints without guessing replacement values.
  5. I test against the receiving application and read any remaining rejection message.

I don't present JSON Formatter and Validator as proof that an API will accept your payload. Its syntax check is one part of the work. If I convert tabular data with CSV to JSON, I also inspect the resulting types and structure. A successful conversion isn't a substitute for the receiving system's contract.

How do I handle sensitive JSON and large files safely?

Before pasting, I look for passwords, access tokens, personal data, and confidential records. A tool running in a browser doesn't by itself prove that input stays on your device. I don't claim local processing, a retention policy, or a file-size limit without verified information. If the handling is unclear, I use an approved local parser for sensitive content.

I choose the checking method based on the data, not just convenience.
SituationMy choiceWhat I watch for
Small public exampleOnline syntax validationComplete input and an understandable error
Confidential payloadApproved local parserKeeping secrets out of unverified services
Very large or deeply nested fileLocal tooling suited to the fileSize, nesting, and parser limits
Repeated project checksValidation in the project's workflowUsing requirements that match the target application

For large files, I don't promise a universal upload limit or processing time. RFC 8259 allows parser-specific limits on text size, nesting, strings, and numbers. If a browser check stalls, repeatedly pasting the same large input isn't my preferred fix. I switch to suitable local tooling and distinguish a resource limit from a genuine syntax error.

For JSON exchanged between systems outside a closed environment, I check UTF-8 encoding as required by RFC 8259. Before finishing, I validate the complete document, review any repaired values, and check the receiver's requirements. I also avoid accepting automatic repairs blindly. A repair that guesses a missing value can produce valid JSON while changing what your data means.

Questions people ask

How do I validate JSON online?

I paste the complete, non-sensitive JSON value into JSON Formatter and Validator and run the check. If parsing fails, I inspect the reported location and the text before it. I fix one clear issue, validate again, and review the corrected structure before using the result.

Why is my JSON invalid?

I first check for missing separators, trailing commas, single quotes, unquoted property names, and unmatched brackets. I also look for incorrectly escaped strings and literals such as True instead of true. If those look right, I check whether I copied a complete value rather than a fragment or JavaScript example.

Why does the error point to the wrong line?

I treat the location as where the parser stopped understanding the text. A missing comma or unfinished string can begin earlier than that point. I inspect the preceding text and surrounding structure, then fix the first clear problem. Different parsers can report the same underlying mistake differently.

Can JSON contain comments or trailing commas?

I don't put comments or trailing commas in strict JSON because neither is allowed. Some configuration formats accept extensions, including JSONC or JSON5 features, but I check the target parser's documentation first. An example accepted by a configuration system may still be rejected by a strict JSON checker.

Does a JSON validator check whether my API will accept the data?

I don't take a successful syntax result as API approval. The request can still have missing fields, wrong types, or values that fail application rules. I check the applicable schema and API documentation after syntax validation, then use the receiving system's response to investigate any remaining problem.

Is it safe to paste sensitive JSON into an online validator?

I wouldn't paste secrets into an online validator without understanding its data handling. Browser access alone doesn't establish that processing stays local. For passwords, tokens, personal records, or confidential payloads, I prefer an approved local parser. For public examples, I still check that no private values were included accidentally.

What to do next

I start with syntax, then move to meaning. Copy your complete, non-sensitive JSON into JSON Formatter and Validator, run the check, and repair the first clear problem. If the reported line looks fine, inspect the text immediately before it. Validate again after each repair, then review the formatted structure against your original. Before sending the result to an API, check its required fields, types, and other rules. And if the payload contains confidential data or exceeds what your browser can comfortably handle, switch to an approved local parser rather than forcing it through an online check.

Sources I checked

Tools from this guide

Keep reading