Developer
Jul 14, 2026
Why \n Shows Up Literally in Your JSON Output — Escape Sequences, Encoding Layers, and How to Debug Them
JSON's \n is two characters in the file (backslash + n) that parse to one character (line feed) — and when encoding is applied in the wrong order or twice, you get literal \n in displayed output, double-escaped \\u sequences, or & where & should be. Here's the three encoding layers that commonly stack incorrectly, the specific corruption patterns and their causes, and why \/ appears in some JSON (HTML injection defence in script tags).