onlineunicodetools logo

String literal creator

World's simplest unicode tool

This browser-based utility converts Unicode text to a string literal. Anything that you paste or enter in the text area on the left automatically gets converted to a string literal on the right. It supports the most popular Unicode encodings (such as UTF-8, UTF-16, UCS-2, UTF-32, and UCS-4) and it works with emoji characters. You can use code points or bytes in the literal sequences as well as customize their format. You can also change the literal delimiter and create a proper string by wrapping it in double quotes. Created by encoding gurus from team Browserling.
announcement we've created devurls!
We just created another project – DEVURLS – world's simplest developer news aggragator. Check it out!
String Literal Format
Use code points in string literals.
Use bytes in string literals.
Use this symbol to delimit individual escape codes.
Convert escape codes to uppercase.
Wrap output in double quote marks.
Code Point Format
Choose format for code points.
Set a custom code point format here.
Valid formats are %B – binary, %O – octal, %D – decimal, %H – hex, %U – surrogate pair. Use \B, \O, \D, \H, \U to write literal letters B, O, D, H, U.
Byte Format
Choose format for bytes.
Set a custom byte format here. (See custom code points for format.)
Choose input encoding here.
When using UTF16, UTF32, UCS2, or UCS4 encodings, add a BOM indicator before the string literal.
String literal creator tool What is a string literal creator?
This utility converts Unicode glyphs to literal strings that you can use in various programming languages and configuration files. It takes the input Unicode data, converts it to binary bytes and code positions, and outputs them as a sequence of escape codes. You can use eight different formats for code positions, such as Java escape codes (\uHHHH), Ruby escape codes (\u{HHHH}), HTML, XML, and XHTML escape codes (&#D; and &#xHH;), and others. If none of these formats are suitable for you, you can define your own format. To do this, select the "custom" code point format and enter your own format. To print binary code positions, use %B notation, octal code positions – %O, decimal – %D, hexadecimal – %H, or hexadecimal surrogate pairs – %U. To write ordinary letters B, O, D, H, U, add a backslash in front of them. For example, \B will write B and \\ will write a slash. There are sixteen different formats for working with bytes, including Perl escape codes (\x{HH}), SQL escape codes (#HH#), and C escape codes (\xHH). You can also set a custom escape format for bytes using the same notation as for code points (except %U). Additionally, for byte escape codes, you can choose the Unicode encoding of your data. We support UTF-8 (default), UCS-2, UTF-16-LE, UTF-16-BE, UCS-4, UTF-32-LE, and UTF32-BE encodings and optionally you can add a Byte Order Mark (BOM). You can also print escape codes in uppercase and change the delimiter that gets placed between escape codes. To make the string literal immediately usable, you can also wrap the output in double quotation marks.
String literal creator examples Click to use
Java String Literal
In this example, we convert a quote from Albert Einstein to a Java string literal. We use the u-prefix format, which converts each Unicode character to a hexadecimal code point pair and adds the prefix \u in front. We wrap the string literal in double quotes and you can paste it directly in your JavaScript code and it will work.
The only source of knowledge is experience
"\uff34\uff48\uff45\u0020\uff4f\uff4e\uff4c\uff59\u0020\uff53\uff4f\uff55\uff52\uff43\uff45\u0020\uff4f\uff46\u0020\uff4b\uff4e\uff4f\uff57\uff4c\uff45\uff44\uff47\uff45\u0020\uff49\uff53\u0020\uff45\uff58\uff50\uff45\uff52\uff49\uff45\uff4e\uff43\uff45"
Required options
These options will be used automatically if you select this example.
Use code points in string literals.
Use this symbol to delimit individual escape codes.
Convert escape codes to uppercase.
Wrap output in double quote marks.
Choose format for code points.
Unicode Snail
This example encodes snail art created from various Unicode characters to a literal hex string. It applies UTF8 curly-hex-byte format used in Perl code to every character. This format puts hex bytes in curly brackets and adds a backslash and the hex prefix "x" before each byte. The bytes are printed in uppercase and they are separated by the space symbol.
.----. @ @ / .-"-.`. \v/ | | '\ \ \_/ ) ,-\ `-.' /.' / '---`----'----' hjw
\x{20} \x{20} \x{20} \x{20} \x{2E} \x{2D} \x{2D} \x{2D} \x{2D} \x{2E} \x{20} \x{20} \x{20} \x{40} \x{20} \x{20} \x{20} \x{40} \x{0A} \x{20} \x{20} \x{20} \x{2F} \x{20} \x{2E} \x{2D} \x{22} \x{2D} \x{2E} \x{60} \x{2E} \x{20} \x{20} \x{5C} \x{76} \x{2F} \x{0A} \x{20} \x{20} \x{20} \x{7C} \x{20} \x{7C} \x{20} \x{27} \x{5C} \x{20} \x{5C} \x{20} \x{5C} \x{5F} \x{2F} \x{20} \x{29} \x{0A} \x{20} \x{2C} \x{2D} \x{5C} \x{20} \x{60} \x{2D} \x{2E} \x{27} \x{20} \x{2F} \x{2E} \x{27} \x{20} \x{20} \x{2F} \x{0A} \x{27} \x{2D} \x{2D} \x{2D} \x{60} \x{2D} \x{2D} \x{2D} \x{2D} \x{27} \x{2D} \x{2D} \x{2D} \x{2D} \x{27} \x{20} \x{68} \x{6A} \x{77}
Required options
These options will be used automatically if you select this example.
Use bytes in string literals.
Use this symbol to delimit individual escape codes.
Convert escape codes to uppercase.
Wrap output in double quote marks.
Choose format for bytes.
Choose input encoding here.
Medical Emojis
In this example, we create our own custom string literal using a custom byte format. We select the "custom" format from the byte format list and enter the format value "#$%H". The first two characters "#$" are the escape prefix and the last two "%H" correspond to a non-padded hexadecimal byte value. We set the escape code separator symbol to a comma to clearly show each byte and wrap the entire sequence in quotes. The input medicine emoticons are encoded as UTF-16 Little Endian bytes with a BOM indicator (the first two bytes).
💊 – pill 💉 – syringe 🧪 – test tube 🧫 – petri dish 🧬 – DNA double-helix
"#$FF, #$FE, #$3D, #$D8, #$8A, #$DC, #$20, #$0, #$13, #$20, #$20, #$0, #$70, #$0, #$69, #$0, #$6C, #$0, #$6C, #$0, #$A, #$0, #$3D, #$D8, #$89, #$DC, #$20, #$0, #$13, #$20, #$20, #$0, #$73, #$0, #$79, #$0, #$72, #$0, #$69, #$0, #$6E, #$0, #$67, #$0, #$65, #$0, #$A, #$0, #$3E, #$D8, #$EA, #$DD, #$20, #$0, #$13, #$20, #$20, #$0, #$74, #$0, #$65, #$0, #$73, #$0, #$74, #$0, #$20, #$0, #$74, #$0, #$75, #$0, #$62, #$0, #$65, #$0, #$A, #$0, #$3E, #$D8, #$EB, #$DD, #$20, #$0, #$13, #$20, #$20, #$0, #$70, #$0, #$65, #$0, #$74, #$0, #$72, #$0, #$69, #$0, #$20, #$0, #$64, #$0, #$69, #$0, #$73, #$0, #$68, #$0, #$A, #$0, #$3E, #$D8, #$EC, #$DD, #$20, #$0, #$13, #$20, #$20, #$0, #$44, #$0, #$4E, #$0, #$41, #$0, #$20, #$0, #$64, #$0, #$6F, #$0, #$75, #$0, #$62, #$0, #$6C, #$0, #$65, #$0, #$2D, #$0, #$68, #$0, #$65, #$0, #$6C, #$0, #$69, #$0, #$78, #$0"
Required options
These options will be used automatically if you select this example.
Use bytes in string literals.
Use this symbol to delimit individual escape codes.
Convert escape codes to uppercase.
Wrap output in double quote marks.
Choose format for bytes.
Set a custom byte format here. (See custom code points for format.)
Choose input encoding here.
When using UTF16, UTF32, UCS2, or UCS4 encodings, add a BOM indicator before the string literal.
Pro tips Master online unicode tools
You can pass input to this tool via ?input query argument and it will automatically compute output. Here's how to type it in your browser's address bar. Click to try!
https://onlineunicodetools.com/convert-unicode-to-string-literal?input=%EF%BC%B4%EF%BD%88%EF%BD%85%20%EF%BD%8F%EF%BD%8E%EF%BD%8C%EF%BD%99%20%EF%BD%93%EF%BD%8F%EF%BD%95%EF%BD%92%EF%BD%83%EF%BD%85%20%EF%BD%8F%EF%BD%86%20%EF%BD%8B%EF%BD%8E%EF%BD%8F%EF%BD%97%EF%BD%8C%EF%BD%85%EF%BD%84%EF%BD%87%EF%BD%85%20%EF%BD%89%EF%BD%93%20%EF%BD%85%EF%BD%98%EF%BD%90%EF%BD%85%EF%BD%92%EF%BD%89%EF%BD%85%EF%BD%8E%EF%BD%83%EF%BD%85&use-code-point=true&code-point-format=u-prefixed-surrogate&uppercase=false&separator=&wrap-in-quotes=true
All unicode tools
Didn't find the tool you were looking for? Let us know what tool we are missing and we'll build it!
Quickly find code positions of all Unicode values.
Quickly decode code positions to Unicode values.
Quickly encode Unicode values to UTF-8 encoding.
Quickly encode Unicode values to UTF-16 encoding.
Quickly encode Unicode values to UTF-32 encoding.
Quickly create a picture from Unicode symbols.
Quickly generate random Unicode text in a given range.
Quickly generate all Unicode values from the given code point interval.
Quickly filter Unicode symbols that are within the given code point interval.
Quickly split Unicode data into graphemes.
Quickly sort Unicode glyphs in increasing or decreasing order.
Quickly find the length of Unicode text.
Quickly increase Unicode code point values.
Quickly decrease Unicode code point values.
Quickly reverse the order of symbols in Unicode text.
Quickly rotate Unicode characters to the left and right.
Quickly create multiple copies of Unicode text.
Quickly extract all characters from Unicode text.
Quickly split Unicode data into pieces.
Quickly split Unicode text into chunks of constant length.
Quickly merge Unicode snippets together.
Quickly shorten Unicode text to the given length.
Quickly left-pad Unicode text with any character.
Quickly right-pad Unicode text with any character.
Quickly align Unicode data to the center.
Quickly align Unicode data to the right.
Quickly convert ordinary numbers to Unicode numbers in various fonts.
Quickly convert ordinary letters to Unicode letters in various fonts.
Quickly convert ordinary text to fancy Unicode text.
Quickly combine input Unicode with diacritical marks.
Quickly spoof regular text using Unicode homoglyphs.
Quickly circularly rearrange Unicode symbols.
Quickly convert Unicode data to escape sequences.
Quickly encode Unicode data to HTML entities.
Quickly URL-escape Unicode symbols.
Quickly encode Unicode values to base64.
Quickly encode Unicode values to a data URI.
Quickly convert Unicode characters to raw bytes.
Quickly convert Unicode data to base-2 (binary).
Quickly convert Unicode data to base-8 (octal).
Quickly convert Unicode data to base-10 (decimal).
Quickly convert Unicode data to base-16 (hexadecimal).
Quickly convert Unicode symbols to raw ASCII bytes.
Quickly convert ASCII bytes to Unicode symbols.
Quickly convert Unicode text to a string literal.
Quickly create a picture from Unicode emojis.
Release Zalgo on your Unicode text.
Coming soon These unicode tools are on the way
Name Unicode Symbols
Spell out the names of Unicode characters in the input text.
URL-decode Unicode
URL-unescape Unicode text.
Convert Binary to Unicode
Convert base-2 data to Unicode encoding.
Convert Octal to Unicode
Convert base-8 data to Unicode encoding.
Convert Decimal to Unicode
Convert base-10 data to Unicode encoding.
Convert Hex to Unicode
Convert base-16 data to Unicode encoding.
Convert Unicode to Any Base
Convert Unicode text to any radix.
Convert Any Base to Unicode
Convert any radix data to Unicode.
Convert Unicode to Latin1
Convert Unicode text to Latin1 encoding.
Convert Latin1 to Unicode
Convert Latin1 encoded data to Unicode.
Convert Bytes to Unicode
Convert raw bytes to Unicode.
Remove Combining Characters
Delete diacritical marks from Unicode data
Remove Zalgo from Unicode
Make Unicode Zalgo text readable again.
Validate Unicode
Check if the given Unicode has valid encoding.
Convert Unicode to Punycode
Encode Unicode text to Punycode encoding.
Convert Punycode to Unicode
Decode Punycode encoding to Unicode.
Decode Base64 to Unicode
Convert base64 data to Unicode text.
Encode Unicode to Data URI
Convert Unicode to a valid data URL.
Decode Data URI to Unicode
Convert a valid data URL to Unicode text.
Convert HTML to Unicode
Decode HTML entities to Unicode data.
Convert UTF8 to Unicode
Decode UTF8 encoding to Unicode.
Convert UTF16 to Unicode
Decode UTF16 encoding to Unicode.
Convert UTF32 to Unicode
Decode UTF32 encoding to Unicode.
Convert Unicode to Uppercase
Convert all Unicode characters to uppercase.
Convert Unicode to Lowercase
Convert all Unicode characters to lowercase.
Convert Unicode to Randomcase
Randomize case of all Unicode characters.
Convert Unicode to Lowercase
Convert all Unicode characters to lowercase.
JSON Stringify Unicode
Encode Unicode to JSON.
JSON Parse Unicode
Decode JSON to Unicode.
Shuffle Unicode Symbols
Randomly rearrange the order of input graphemes.
Analyze Unicode
Print statistics about Unicode data and code points, etc.