iriapractical guide

The JSON parses but shows backslash-n: check which line break you intended

An adult compares blank paper strips beside a laptop.

AI-generated image; illustrative scene.

Decide what the application should receive

A valid JSON file can contain a line-feed character or the two visible characters backslash and n. Those are different values. Before translating, check which value the application reading the resource needs; a parser does not choose your intended layout.

For this original example, we agree on a two-line message: a greeting followed by the notice below it. Our example’s destination application is prepared to display that line break. We do not claim every interface control does so: check the real integration.

Two files that parse but contain different values

This is the invented Spanish entry, as written in a JSON file:

{"message": "Hola\nTu pedido está listo"}

Parsing that JSON turns \n into a line-feed character. An English translation preserving our contract would be:

{"message": "Hello\nYour order is ready"}

This other JSON contains a different value:

{"message": "Hello\\nYour order is ready"}

Here \\ represents a literal backslash followed by the letter n. The resulting value contains those two characters, not the earlier line break. That text is not wrong for every purpose: it would be appropriate if you wanted to teach the literal sequence. It fails the two-line contract we chose for this message.

The distinction follows JSON string escapes in RFC 8259, section 7. A raw unescaped newline inside the JSON string is not the way to write this example either: the file needs a valid representation for its parser to interpret.

Check a sample before repeating the change

  1. Keep the original file and record the destination: a JSON resource, not a string pasted inside another programming language.
  2. Translate the value’s text while retaining the message key and the line break required by the contract.
  3. Parse a sample with your project’s parser and check the resulting value. Do not count backslashes only in a debugging representation: it may escape them again.
  4. Check the message in the destination control. A value containing a line break does not itself establish that the control displays two lines.

If the resource travels inside another JSON object as text or inside code, there is another representation layer. Do not replace every backslash in the project to fix one sample: identify each layer and what its reader expects first.

What Iria adds and what you still review

The Iria facts page documents Localization Studio with JSON and RESX projects, context and reviews. Its structural checks do not establish translation meaning or quality. Nor have we established here that they detect this specific contract failure: a person reviews the sample and presentation contract.

Iria is a paid local Windows translator; activation and initial model download need a connection. Check its facts page and the linked Studio guide to choose an appropriate workflow. If you simply wanted to translate selected text in another application, this JSON-file example adds a layer you may not need.

Related articles

Back to blog
Buy Iria — EUR 19.99