URL, HTML, Base64 Encoder & Decoder — Free Online Tool

Encode and decode URL parameters, HTML entities, Base64 strings, JavaScript string escapes, and Unicode escape sequences. Auto-detect encoding type, swap input/output with one click, and upload files for Base64 conversion. 100% client-side — nothing is sent to any server.

Encoder / Decoder


Input 0 chars
Output
0 chars

What is encoding and decoding? Encoding rewrites text into a restricted character set so it survives a context that would otherwise misread it — a URL, an HTML document, a JSON string, an email body. Decoding reverses that rewrite. It is a reversible transformation, not encryption: anyone can undo it, and nothing is kept secret. This tool covers the five schemes developers meet daily — URL percent-encoding, HTML entities, Base64, JavaScript string literals and Unicode escapes.

How to Use the Encoder / Decoder

  1. Pick the tab that matches the context — Choose URL for anything going into an address bar or query string, HTML for text rendered inside a page, Base64 for binary or credentials, JS String for a value pasted into source code, or Unicode for escape sequences. Each tab has its own variant buttons underneath.
  2. Set the direction with Encode or Decode — The two buttons above the panels flip which way the transformation runs. In decode mode the panel labels change to Encoded Input and Decoded Output, so you can tell at a glance which side is which.
  3. Type or paste into the left panel — The output recalculates on every keystroke — there is no run button. The character counts above each panel update with it, which is the quickest way to see how much a scheme inflates your data; Base64 adds roughly a third, and percent-encoding can triple a string of punctuation.
  4. Choose the variant that matches your target — The variant row is where most mistakes are avoided: encodeURIComponent versus encodeURI for URLs, named versus numeric HTML entities, single, double, backtick or template quoting for JavaScript, and \uXXXX, \UXXXXXXXX or \xHH for Unicode.
  5. Use Auto-Detect on input you did not createAuto-Detect scores the input against patterns for all five schemes, switches to the winning tab and shows a badge naming it. It is a heuristic — percent signs, ampersand-semicolon pairs and backslash-u sequences are strong signals, while short Base64-looking strings are easy to mistake.
  6. Reverse with Swap, or load a fileSwap moves the output back into the input and flips the mode, which round-trips a value in one click and is the fastest way to check that a decode was lossless. In the Base64 tab, Upload File reads a file with FileReader and puts its Base64 payload in the output panel while the input panel shows the file name.

The Five Schemes and How Each One Works

All five schemes solve the same problem in different alphabets: a character that means something structural in the destination has to be carried through it as data. The differences are which characters count as dangerous, and what the replacement looks like.

URL percent-encoding (RFC 3986)

A reserved or unsafe character is replaced by a percent sign and the two hexadecimal digits of each of its UTF-8 bytes: a space becomes %20, an ampersand %26, and the euro sign, being three bytes in UTF-8, becomes %E2%82%AC. Which characters get replaced depends on the mode. The encodeURIComponent button uses the browser's built-in function of that name, which leaves only letters, digits and - _ . ! ~ * ' ( ) alone — that is what you want for a single query value, because it encodes the &, =, ? and / that would otherwise be read as structure. The encodeURI button preserves those separators, so it is for encoding a whole address you have already assembled. Full URI is a looser third mode that only replaces characters outside the RFC 3986 reserved and unreserved sets; note that it deliberately leaves spaces untouched, so it is a repair pass for a nearly-valid URL rather than a general encoder.

HTML entity encoding

Entity encoding stops a browser from reading your text as markup, which is the core defence against reflected and stored cross-site scripting. In Named mode this tool escapes the seven characters that actually matter in an HTML or attribute context — &, <, >, ", ', backtick and / — and leaves everything else, including accented letters and symbols, as literal UTF-8. That is the modern recommendation: a page served as UTF-8 does not need &eacute; for é. Numeric mode is the aggressive option, converting every character above code point 127 into a &#NNN; reference, which is what you want when the output has to survive an ASCII-only pipeline. Decoding accepts both forms plus hexadecimal &#xHH; references and a long table of named entities.

Base64 (RFC 4648)

Base64 re-expresses arbitrary bytes in a 64-character alphabet that survives text-only channels. Three input bytes — 24 bits — are split into four 6-bit groups, and each group indexes the alphabet A–Z a–z 0–9 + /. When the input length is not a multiple of three, the output is padded with one or two = characters, which is why encoded lengths are always a multiple of four:

encoded length = 4 × ⌈bytes / 3⌉ (about 33% larger than the input)

Text is converted to UTF-8 bytes before encoding, so accented letters, CJK text and emoji survive a round trip. Decoding strips whitespace and line breaks first, so Base64 copied out of a MIME email or a PEM-style block with 64- or 76-column wrapping pastes in directly. Base64 is an encoding, not a cipher — a Base64 credential is one atob call away from plaintext.

JavaScript string literals

This tab wraps your text in the quote style you choose and escapes what would otherwise terminate or corrupt the literal: backslashes are doubled, newlines and tabs become \n and \t, the enclosing quote character is backslash-escaped, and control characters become \xHH or \uXXXX. Template-literal mode also escapes $ so an accidental ${...} is not interpolated. Backtick mode leaves single and double quotes alone, because neither ends a template literal.

Unicode escapes

The Unicode tab converts every character to a numeric escape sequence, which is how you embed non-ASCII text in a source file, a properties file or a JSON payload that must stay ASCII-only. The tool walks the string by UTF-16 code unit, so a character outside the Basic Multilingual Plane — most emoji, for instance — is emitted as its two surrogate halves rather than as one code point: the grinning-face emoji at U+1F600 becomes \uD83D\uDE00, and in the eight-digit mode \U0000D83D\U0000DE00. Decoding is more capable than encoding here and will correctly rebuild a real \U0001F600 escape written by another tool. The \xHH mode uses two digits for code points up to 255 and silently falls back to \uXXXX above that.

Encoding Reference

The same handful of characters cause almost every encoding bug. This is what each scheme turns them into.

CharacterURL (component)HTML namedHTML numericJS string
space%20unchangedunchangedunchanged
&%26&amp;&#38;unchanged
<%3C&lt;&#60;unchanged
>%3E&gt;&#62;unchanged
"%22&quot;&#34;\" in double-quote mode
'%27&#39;&#39;\' in single-quote mode
/%2F&#47;&#47;unchanged
?%3Funchangedunchangedunchanged
#%23unchangedunchangedunchanged
=%3Dunchangedunchangedunchanged
+%2Bunchangedunchangedunchanged
at sign%40unchangedunchangedunchanged
newline%0Aunchanged&#10;\n
é (U+00E9)%C3%A9unchanged&#233;unchanged

Named mode escapes only the seven structurally dangerous characters. It will not turn © into &copy; or an em dash into &mdash; — those are left as UTF-8, which every modern browser renders correctly. Use Numeric mode if you genuinely need an ASCII-only document. Decoding, by contrast, understands the full named-entity table.

Choosing the Right Encoding

The rule that prevents most bugs is to encode at the moment of insertion, for the context you are inserting into, and exactly once. Encoding early and carrying the encoded value through your code leads to double-encoding, where %20 becomes %2520 and &amp; shows up on screen as literal text. Encoding for the wrong context is worse: HTML-escaping a value and then putting it in a URL protects nothing, because the browser never applies HTML rules to a query string.

  • URL: every value you append to a query string, path segment or form body. Use component mode for the value, not for the whole address.
  • HTML: every piece of user-supplied text rendered into a page — comments, names, search terms echoed back. Escape on output, not on input, so the stored data stays clean.
  • Base64: binary carried through a text channel — inline images in CSS, attachments in JSON, HTTP Basic credentials, the segments of a JWT. Never as a substitute for encryption.
  • JS string: a literal you are pasting into source, a config file or a test fixture. For values injected into a page at runtime, serialise with JSON.stringify in your own code instead.
  • Unicode escape: ASCII-only source and config formats, and inspecting text that contains invisible characters — zero-width spaces and non-breaking spaces become plainly visible as \u200B and \u00A0.

Frequently Asked Questions

Use encodeURIComponent for a single value you are about to drop into a URL — it encodes everything except A–Z, a–z, 0–9 and - _ . ! ~ * ' ( ), including the &, =, ? and / that would otherwise be read as structure. Use encodeURI only on a complete address you have already assembled, since it deliberately preserves those separators. Encoding a whole URL with component mode produces a string that is no longer a URL.

No, and treating it as one is a common and costly mistake. Base64 is a reversible mapping between bytes and a 64-character alphabet with no key and no secret — the decode button on this page undoes it, as does one atob() call in any browser console. HTTP Basic credentials and the header and payload of a JWT are Base64, which is exactly why both are only safe over TLS. Use hashing or real encryption when the content needs to stay unreadable.

It selects which pair of browser APIs performs the byte conversion: checked uses TextEncoder and TextDecoder, unchecked uses the older escape/unescape idiom around btoa and atob. Both paths treat the text as UTF-8, so for ordinary input the encoded output is identical either way and multi-byte characters survive in both. Leave it on — the modern APIs give clearer errors on malformed input.

Named mode escapes exactly seven: &, <, >, double quote, single quote, backtick and /. That is the set that can break out of an HTML or attribute context, and it is deliberately not a full entity table — é, © and em dashes are left as UTF-8, which every current browser renders correctly. Numeric mode is the stricter option and converts every character above code point 127 to a &#NNN; reference for ASCII-only output.

It scores the input against all five schemes and picks the highest. Runs of %XX sequences score for URL; &name;, &#NN; and &#xHH; score for HTML; a string made only of A–Z a–z 0–9 + / = that also survives an atob() test scores for Base64; leading and trailing quotes plus backslash escapes score for JS; and \uXXXX or \UXXXXXXXX runs score for Unicode. If nothing scores it says so rather than guessing. Short inputs are the unreliable case — plain words are valid Base64.

Yes. Open the Base64 tab and use the Upload File button — the file is read locally with FileReader and the Base64 payload appears in the output panel while the input panel shows the file name. There is no drag-and-drop target on this page, so use the button. Nothing is uploaded; if you want a dedicated page for this, the Base64 File tool handles files and data URIs directly.

No request is made with your content — every transformation runs in JavaScript in the tab. One thing is worth knowing before you share a link, though: the input panel's contents are written into the page URL as a query parameter on every keystroke so the state can be bookmarked. That URL lands in your browser history and in anything you paste it into, so clear the panel with the Clear button before copying the address if you have been decoding a token, a session cookie or a JWT.

That is a defect in the current escaping pass rather than something you did. The step that is meant to escape the backspace control character is written as a word-boundary pattern, so a literal \b is inserted at every word boundary — "Hello World" comes out as '\bHello\b \bWorld\b'. The quoting, backslash doubling, newline and tab handling are all correct. Until this is fixed, delete the stray \b pairs after copying, or use the Unicode tab if all you need are escape sequences.

Use Cases

Building a Query String by Hand

You are testing an endpoint in curl or Postman and the search term contains a space, an ampersand and a plus sign. Encode just that value in component mode and paste it after the equals sign, instead of guessing which characters the client will escape for you.

Reading an Authorization Header

A request log shows Authorization: Basic followed by a blob. Decode it in the Base64 tab to confirm which account a failing integration is actually presenting — and to see immediately why Basic auth over plain HTTP is not a secret.

Putting a Code Sample in a CMS Field

Pasting markup into a page editor makes the browser render it instead of showing it. Run the snippet through HTML encode first so the tags survive as visible text, and confirm the escaping matches what the template expects.

Finding an Invisible Character

A string comparison fails even though both values look identical on screen. Paste one into the Unicode tab and the culprit shows up as a numbered escape — usually a zero-width space, a non-breaking space or a curly quote pasted in from a document.

Diagnosing Double-Encoding

A link arrives containing %2520 or a page shows a literal &amp;amp;. Decode once, look at the result, decode again — the number of passes needed tells you how many layers of encoding the pipeline is applying.

Inlining a Small Image or Font

Upload an icon in the Base64 tab and paste the result into a CSS url(data:...) rule or an email template, trading one HTTP request for roughly a third more bytes — worth it for assets of a few kilobytes, rarely for anything larger.