The JSON was valid five minutes ago. Then you pasted in one real sentence: a customer quote, a Windows file path, an address that wraps onto a second line. Now the file will not parse, and the error names a character halfway through a word you did not touch.

Almost every failure of this kind comes from inside a string, where three ordinary characters stop being plain text. This guide explains what those characters do, why the reported error seems to point at the wrong place, and how to repair the string by hand with the JSON Formatter and Validator on Ovatly, which runs in your browser and uploads nothing.

Contents

  • Quick answer
  • The three characters that break strings
  • Why the error seems to point at the wrong place
  • How to fix unescaped characters, step by step
  • Worked example: a quote that ended the string early
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

An unescaped character error means a string contains a character JSON treats as structure: a double quote that ends the string early, a backslash that starts an escape you did not intend, or a raw line break, which is illegal inside a string. Paste the JSON into the JSON Formatter and Validator and use Validate only: it checks the text without changing it and names the problem in plain words. Be clear about the division of labour: the validator names the problem, it does not repair your text. You fix the string yourself, by escaping the quote, doubling the backslash or rewording the value, and then you validate again.

The three characters that break strings

A JSON string is text between double quotes, and the parser reads it with simple rules. Almost anything is allowed inside, except a handful of characters that have jobs of their own.

A double quote ends the string. The parser cannot tell your punctuation from its delimiter. When a value contains a quote, as in a line of dialogue or a measurement in inches, the first inner quote closes the string. Everything after it is then read as JSON structure, and it is usually nonsense in that role, so the parser reports an unexpected character a little further along.

A backslash starts an escape. Inside a string, a backslash is never just a backslash: it introduces an escape sequence. Some sequences are valid but mean something else entirely, so a file path can end up silently wrong rather than broken. Others are not valid escapes at all, and the parser stops on them. Either way, a lone backslash in copied text is a suspect.

Control characters are illegal raw. A string cannot contain a literal line break. Text pasted from an email, a form or a document often carries real line breaks inside what should be one value, plus the occasional stray tab. The grammar forbids them unescaped, so a perfectly ordinary address can make a whole file unparseable.

Why the error seems to point at the wrong place

The parser reads from the start and complains at the first character it cannot make sense of. That character is where reading failed, which is not always where you made the mistake. If a quote ends a string three words early, the parser keeps going: it treats the following words as keys, values or punctuation, and only trips when it meets something that no reading can rescue. The reported spot is the end of the confusion, not the start of it.

So read the error as a boundary. The fault sits at the reported character or, more often, shortly before it, inside the nearest string. Checking just upstream turns a baffling message into a precise one.

How to fix unescaped characters, step by step

  1. Open the JSON Formatter and Validator and paste in the JSON.
  2. Choose Validate only. This checks the text without changing it, and reports the problem in plain words, such as an unexpected character or a missing comma.
  3. Find the string nearest to, and just before, the reported spot. Look inside it for a quote, a backslash or a line break that arrived with the original text.
  4. Fix that character by hand: put a backslash before an inner quote so it reads as \", double a backslash that should stay literal so it reads as \\, and either replace a raw line break with the escape sequence \n or reword the value so it sits on one line.
  5. Validate again. Parsers stop at the first error, so a file with two bad strings needs two rounds. Once it validates clean, format it with a 2 or 4 space indent if you want the readable version.

Worked example: a quote that ended the string early

Here is a small object holding a note copied from a customer message:

{"note": "She said "hello" and left"}

The string ends at the quote just before hello. The parser then meets hello where it expected a comma or a closing brace, and reports an unexpected character. The fix is to escape the inner quotes so they are read as text rather than delimiters:

{"note": "She said \"hello\" and left"}

Backslashes cause the same class of failure. This path looks harmless:

{"path": "C:\data\file.txt"}

It is invalid, because \d is not an escape sequence JSON recognises. Doubling each backslash makes them literal characters instead:

{"path": "C:\\data\\file.txt"}

Both repairs are one small edit.

Limitations and honest tradeoffs

The validator names problems; it does not fix them. There is no automatic repair, and that is deliberate: a tool that guessed at your text could change a value's meaning while making the file parse. The edit stays yours.

The standard it enforces is strict JSON. Trailing commas, single-quoted strings and unquoted keys are all invalid, and comments are not allowed at all: there is no JSONC support, so a commented configuration file will fail here even though some other tools accept it. Text copied from JavaScript objects or Python dictionaries usually needs converting before it validates.

Two smaller notes. Number precision follows JavaScript, so an integer beyond 2^53 can lose exactness when the text is reformatted; Validate only, which does not reformat, avoids touching the digits at all. And very large pastes may take a moment to check. Everything runs fully locally in your browser, so nothing you paste is sent anywhere.

Common mistakes

  • Deleting the character the error names. The reported character is often innocent; the unescaped quote or backslash just before it is the fault. Edit upstream, not at the marker.
  • Escaping everything in sight. Doubling every backslash in a file corrupts values that were already correct. Fix the one string the error implicates, then revalidate.
  • Switching to single quotes to dodge the problem. Single-quoted strings are invalid JSON, so the file fails again for a new reason.
  • Pasting multiline text straight into a value. Addresses, messages and descriptions carry real line breaks. Flatten them or escape them before the text goes in.
  • Assuming one fix is the whole job. The parser stops at the first error. Validate again after every fix until the result comes back clean.

FAQs

Does the validator fix the broken characters for me? No. The tool names the problem, for example an unexpected character or a missing comma, and leaves your text untouched. The repair is a manual edit: escape the inner quote, double the backslash, or reword the value, then validate again to confirm the fix.

Which characters have to be escaped inside a JSON string? The double quote and the backslash always do: a quote inside a value needs a backslash in front of it, and a literal backslash needs to be doubled. Control characters cannot appear raw either, so a real line break inside a value must be replaced by its escape sequence or the value reworded onto one line.

Why does the error seem to point past my actual mistake? The parser reads happily until the text stops making sense. An unescaped quote ends the string early, so the words after it are read as structure rather than text, and the parser only trips over a character further along. The real fault is usually just before the reported spot.

Can I use single quotes around a JSON string instead? No. JSON requires double quotes. Single-quoted strings are invalid, as are unquoted keys, trailing commas and comments. Text copied from JavaScript or Python often needs its quotes converted before it will validate.

Is my JSON uploaded anywhere when I validate it? No. The formatter and validator run fully locally in your browser, so you can paste configuration, payloads or private data and none of it leaves your device.

Conclusion

Unescaped character errors feel mysterious because the parser complains downstream of the real fault, but the cast of culprits is short: a quote, a backslash or a raw line break inside a string. Let the JSON Formatter and Validator name the problem, make the small edit yourself, and validate again until it passes. For the other half of the skill, reading the messages themselves, see What Does a JSON Validation Error Message Actually Mean. More guides in this series live in the Data and JSON Tools guides.

References