TokenPad
Format

JSON String Escaper for Prompts

Embed a multi-line prompt inside a JSON field without breaking it.

Your input

61 characters2 lines0 tokensor drop a file

JSON String EscaperExact
0Token change
Token change0no change
Input tokens0what you pasted
Output tokens0what you would send
Token cost of this result
Output tokens0
As input$0.00
× 100K requests$0.00

Everything on this page runs in your browser. Nothing you paste is transmitted, because there is no server here to transmit it to.

Result
 

Why this comes up constantly

Prompts are written as multi-line text and transmitted as JSON strings. Every newline has to become \n, every quote has to be escaped, and doing it by hand in a config file is how a prompt ends up subtly corrupted.

The reverse case is just as common: you have a request log or a saved payload and you want to read the prompt that was actually sent, rather than the one you think was sent.

The debugging use

When a prompt behaves differently in production than in your editor, unescape the string from a real logged request and compare it to your source. Template interpolation, trimming and accidental double-escaping all show up immediately at that point and are nearly invisible before it.

Double-escaping is the classic one: a prompt that passes through two serialisation layers arrives at the model containing literal backslash-n sequences instead of line breaks, and the model reads them as text.

Escaping costs tokens

Each escape sequence is characters the model has to be sent. A prompt with many line breaks measurably grows when escaped, and a doubly-escaped one grows again. The counter shows the escaped size, which is the size you are billed for.

Frequently asked questions

Why does my prompt show literal \n in the model’s view?
It was escaped twice — once by your templating layer and once by your HTTP client. Unescape a real logged request here and you will see it immediately. The fix is to escape once, at the serialisation boundary.
Does escaping change the meaning for the model?
Correct escaping does not: the model receives the original characters. Double-escaping does, because the model then receives the literal backslash and n as two characters rather than a line break.

More format tools