Format Code Now
/
Encode & decodeCode to ASCII Converter Next: Decimal to ASCII ›

Code to ASCII Converter

ED-54

Paste source code or text and make it ASCII-only by replacing non-ASCII characters with escapes, or list the ASCII code of every character.

Runs in your browser. Nothing is uploaded.

Source code or text

Result

How to use it

  1. Paste your code or text into the input box.
  2. Under Non-ASCII characters become, choose \uXXXX escapes, \u{...} escapes, HTML numbers, removal or a question mark.
  3. Click Make ASCII-only to get code that contains only characters 0 to 127.
  4. Or choose a number base and click List ASCII codes to see one code per character.

Making code ASCII-only

Characters from U+0000 to U+007F pass through unchanged. Every other character, such as an accented letter, a currency sign or an emoji, is replaced by what you choose. Escapes keep the meaning, so a JavaScript string with \u00e9 still means é. HTML numbers such as é work in markup. Removing a character or writing ? discards information, so use those only when the character does not matter.

What it does not do

It does not transliterate, so é is not turned into e, and it does not know the language of your code. An escape that is valid in JavaScript, JSON, Java and C# may be meaningless in another language, in a regular expression or in a comment. Check the result in the language you use. Unpaired surrogates in the input are reported, not silently changed.

Listing ASCII codes

List ASCII codes prints one number per character in decimal, hex, binary or octal. Characters above 127 are not ASCII, so for those the Unicode code point is shown. For a full two-way conversion between text and codes, with a choice of UTF-8 bytes, use the ASCII converter page on this site.

Error messages and what to do

MessageWhat it meansFix
The input has an unpaired surrogateThe text holds half of an emoji or similar character, which has no valid code point.Delete the broken character or replace it with the full one.

Questions people ask

How do I convert code to ASCII?

Paste the code, choose how non-ASCII characters should be handled, and click Make ASCII-only. Everything in the 0 to 127 range stays as written, and every other character is replaced by an escape, an HTML number or nothing.

How do I remove non-ASCII characters from text?

Set Non-ASCII characters become to Removed and click Make ASCII-only. All characters above code 127 are deleted. Be careful, because a word such as café turns into caf and the change cannot be undone from the output.

Does it turn é into e?

No. The tool escapes, removes or replaces non-ASCII characters but does not transliterate letters. If you want accent stripping, handle it before pasting, or choose the escape option so the original character is still recoverable.

Why does an emoji become two escapes?

In the \uXXXX form an emoji outside the basic range is written as a surrogate pair of two escapes, which is how JavaScript and JSON write it. The \u{...} form writes one escape per character instead.

What is an ASCII code?

ASCII assigns the numbers 0 to 127 to 128 characters: control codes, digits, letters and basic punctuation. A is 65, a is 97 and the space is 32. Characters outside that range are not ASCII.

Can I convert the ASCII codes of my code to hex?

Yes. Choose Hexadecimal under Codes are written in and click List ASCII codes. You get one two-digit hex value per character. Binary and octal are available as well.

About this tool

Make ASCII-only leaves every character from U+0000 to U+007F as it is and replaces each other character with the escape or marker you choose. The \u form writes emoji as a surrogate pair of two escapes, as JavaScript and JSON expect; the \u{...} form writes one escape per character. Removing or replacing characters with ? loses information, and the tool does not transliterate, so é does not become e. List ASCII codes writes one code per character, using the Unicode code point for anything above 127. It does not know which language the code is written in, so it can break a string that should not contain escapes, such as one in a language without \u.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.