Multi-Language String Escaper
Turn any text into a safe string literal for the language you are writing, or decode an escaped literal back to plain text, with every language side by side and a round-trip check.
ทำงานในเบราว์เซอร์ของคุณ ไฟล์ไม่ออกจากอุปกรณ์ ดูวิธีตรวจสอบ
…
วิธีทำ
- 1Choose the direction
Escape text or decode a literal.
- 2Pick the language
Choose the target language or context.
- 3Paste the input
Paste text or a literal.
- 4Set options
Escape non-ASCII characters if needed.
- 5Check the round trip
Confirm the result decodes exactly.
- 6Copy
Paste the literal into your code.
เกี่ยวกับเครื่องมือนี้
Putting text into source code means escaping it: quotes, backslashes, newlines, tabs and special characters must be written differently in every language. A Windows path, a regular expression, a message with quotes or a snippet with emoji is easy to get subtly wrong, and the mistakes show up as syntax errors or, worse, as text that silently changed. This tool escapes any text into a correct literal for 20 languages and contexts: JSON, JavaScript and TypeScript, Java, C#, C and C++, Go (interpreted and raw), Python (normal and raw), Rust (normal and raw), PHP (single and double quoted), MySQL, PostgreSQL and SQL Server literals, CSS strings, shell single quotes, HTML attributes and regular-expression literal text. It can also decode an escaped literal back to plain text. A round-trip check decodes each result again and confirms you get exactly your input back, and the all-languages table shows every form side by side.
Language notes
- JSON: double quotes, \uXXXX for control characters; U+2028 and U+2029 escaped for safety in JavaScript. - Python raw strings cannot end in a backslash; the tool falls back to a normal string when needed. - Go raw strings cannot contain a backtick; the tool joins parts when needed. - Rust raw strings use as many # marks as necessary so the text cannot end the literal early. - PHP double-quoted strings also escape $ so variables are not interpolated. - PostgreSQL uses doubled quotes in standard strings, and E'…' when backslash escapes are needed. - Shell single quotes cannot contain a single quote, so it is written as '\'' (close, escaped quote, reopen). - CSS escapes use hexadecimal codes followed by a space only when the next character could be read as part of the code.
Non-ASCII characters
By default letters like é and emoji are kept as they are, which all modern source files support in UTF-8. Tick the option to write them as escape codes instead, for files that must stay ASCII.
SQL injection
Escaping literals is fine for scripts and migrations you write by hand. In application code, always use parameterised queries or prepared statements instead of building SQL strings, because escaping rules differ by server settings.
Decoding
Paste a literal including its quotes, choose the language, and switch to decode to see the text it represents, useful for reading escaped strings in logs, JSON or generated code.
Limits
Template literals, f-strings and string interpolation are not evaluated. Character sets other than UTF-8 are not handled. Check generated literals in your compiler or linter; this is a convenience, not a security control.
ตัวอย่างพร้อมวิธีทำ
The text He said "it's done" with a newline, a Windows path and an emoji becomes "He said \"it's done\"\nPath: C:\\temp…" in JSON, r'…' is avoided in Python because of the quotes, and every one of the 20 forms passes the round-trip check.
สรุปสั้น ๆ
- หมวดหมู่: นักพัฒนาและข้อมูล
- ทำงานในเบราว์เซอร์ ไม่ต้องสมัคร ไม่ต้องอัปโหลด
- ข้อมูลที่คุณกรอกอยู่บนอุปกรณ์ของคุณ
- มีภาษาอังกฤษ
- ตรวจสอบเนื้อหาล่าสุด:
- แหล่งข้อมูลทางการ: Language specifications: ECMA-404 (JSON), Java Language Specification 3.10.6, Python lexical analysis, Go and Rust references
คำถามที่พบบ่อย
Which languages are covered?
Twenty forms across JSON, JavaScript, Java, C#, C, Go, Python, Rust, PHP, SQL, CSS, shell, HTML and regular expressions.
Can it decode escaped strings?
Yes. Switch the direction to decode.
What is the round-trip check?
The result is decoded again and compared with your input to prove nothing changed.
Should I escape SQL in my application?
No. Use parameterised queries; escaping is for hand-written scripts.
Are emoji and accents kept?
Yes by default; tick the option to write them as codes.
Is my text uploaded?
No. Everything runs in your browser.
