

Let’s see the complete example that you can directly run in your web browser. Var decodedURL = codeURI(encodedURL) Īlternatively, we can also use the encodeURIComponent( uriToEncode) and decodeURIComponent( encodedURI) function to encode and decode the URI respectively. URIError exception when encodedURI contains invalid character sequences. Syntax var decodedURL = codeURI(encodedURL) ĮndcodedURL– Encoded URI string generated by endcodedURI() function.Ī new string representing the unencoded version of the given encoded Uniform Resource Identifier ( URI). Var encodedURL = window.encodeURI(originalURL)

Syntax var encodedURL = window.encodeURI(uriToEncode) Ī new string representing the provided string encoded as a URI. Var decodedString = window.atob(encodedString) Syntax var decodedString = window.atob(encodedString) ĮncodedString– Encoded string generated by btoa().ĭOMException if encodedString is not valid Base64.Įxample var encodedString = "TG92ZSB0aGUgd2F5IHlvdSBsaWU=" Var encodedString = window.btoa(originalString) InvalidCharacterError– The string contained a character that did not fit in a single byte.Įxample var originalString = "Love the way you lie" StringToEncode– The binary string to encode. Syntax var encodedString = window.btoa(stringToEncode) decodeURI(): It decodes a Uniform Resource Identifier ( URI) previously created by encodeURI() or by a similar routine.Īlternatively, we can also use the encodeURIComponent( uriToEncode) and decodeURIComponent( encodedURI) function to encode and decode the URI respectively.encodeURI(): This encodeURI() function is used to encode a URI.atob(): It decodes a Base64 encoded string created by btoa().btoa(): This function uses the A-Za-z0-9+/= characters to encode the string in Base64.In JavaScript, these are the functions respectively for encoding and decoding Base64 strings and URL. In this short article, we’ll explore JavaScript encoding decoding capabilities. Since + and / characters are not URL and filename safe, The RFC 4648 defines another variant of Base64 encoding whose output is URL and Filename safe. The basic Base64.getEncoder() function provided by the Base64 API uses the standard Base64 alphabet that contains characters A-Z, a-z, 0-9, +, and /. JavaScript Base64 and URL Encoding Decoding Example Java 8 Base64 URL and Filename safe Encoding.
