tools

JavaScript String Escape Online | Developer Tools

JavaScript Escape String Tool

About JavaScript String Escape Tool

This is a free online tool to escape JavaScript strings. You can copy/paste your desired string in below text field and hit Escape button. This tool will help you convert simple string containing newlines \n, quotes (e.g. " & ' ) and some special unicode characters into a quoted string literal value for JSON or Javascript programming source.

What is JavaScript Escaping?

JavaScript escaping is used to represent special meaning characters in a JavaScript code. e.g. less than symbol < has a special meaning in JavaScript programming language. But in case your data contains a less than symbol < and you want to send it without confusing the browser then you need to send it as &lt; instead of < . Simlarly there are many other special characters that can be used as part of JavaScript programming. Below sample list can give you a idea of what this means.

JavaScript Escaping Characters

Character JavaScript Escape Value
quote (") \"
single quote (') \'
Nul char \0
Horizontal Tab \t
Vertical Tab \u000B or \v
New line \n
Carriage return \r
Backslash \\

Want To Know What Is The JavaScript Escaped Value of a Character?

That is easy. Just type the character or a full string in the text box above and hit Escape button. You should be able to see the escaped value.

What Characters Need To Be Escaped?

Only few special meaning character need to be escaped. These characters have special use in JavaScript programming language.

Some Key Things To Note About Escaping In JavaScript

  • Note that the javascript escaped string is not necessarily valid JSON, since control characters are considered illegal in JSON.
  • Note that the \' , \v and \0 escapes are considered illegal in JSON and are not allowed strings.
  • Note that Internet Explorer versions older than 9 takes \v as v instead of a vertical tab \x0B.

Why Do You Need Javascript Online Escape Tool?

JavaScript online string literal escape tool

Escaping a String inside javascript code can be cumbersome task if the string value is large. This kind of tool can easily apply all escaping rules to avoid unwanted errors in a JavaScript code.

Is JavaScript String Escape Value Same As JSON?

JSON and JavaScript escaping is not exactly same. There are few special characters that need to be escaped differently in JSON. Though, most characters are escaped the same way you can not assume it will always be same.

Is JavaScript String Escape Same As escape() function in JavaScript?

The JavaScript escape() function is not same as JavaScript string literal escaping. The JavaScript escape() function is a deprecated (since JavaScript 1.5) function that was used for URL encoding. It is recommended to use encodeURI() instead.

Copyright © FromDev. All rights reserved.