Code & JSON Tools · · 5 min read
How to Encode and Decode Base64, URL, and HTML Text
Encode or decode text as Base64, URL percent-encoding, or HTML entities in one browser tool — UTF-8 safe, swappable, no account needed.
To encode or decode text, open Base64 / URL Encode, pick Base64, URL, or HTML entities from the mode pills, choose Encode or Decode, and paste your text — the result appears instantly, computed entirely in your browser.
What this tool does and why it matters
Three common text transformations keep showing up in everyday development work: Base64 for cramming binary-ish data into text fields (API tokens, data URIs, Basic Auth headers), percent-encoding for putting arbitrary characters safely into a URL, and HTML entity escaping for putting arbitrary characters safely into an HTML page without breaking the markup. They're different problems with different rules, but you often need all three in the same session — so Toolbench puts them in one tool with a mode switch instead of three separate pages. The Base64 mode is UTF-8 safe, so emoji and accented characters round-trip correctly instead of turning into mangled bytes.
How to encode or decode text with Toolbench
- Open Base64 / URL Encode.
- Pick a mode: Base64 (the default), URL, or HTML entities.
- Pick a direction: Encode or Decode.
- Paste or type your text into the input panel on the left.
- Read the result in the output panel on the right. If decoding fails, the output turns red and explains why instead of showing garbage.
- Click Copy to copy the result, or use Send to → to send it straight into another tool.
- Click ⇄ Swap to move the output back into the input and flip the direction — handy for checking a round trip, or for chaining an encode into a decode.
Example: Base64 encode
With Base64 and Encode selected, this input:
Café ☕ open 24/7
produces:
Q2Fmw6kg4piVIG9wZW4gMjQvNw==
Switch to Decode and paste that string back in, and you get Café ☕ open 24/7 again, exactly — the accented é and the ☕ emoji survive the round trip because the tool encodes the UTF-8 bytes of the text, not its raw character codes.
Example: URL encode
With URL and Encode selected, this input:
name=Jordan Lee&role=co-founder
produces:
name%3DJordan%20Lee%26role%3Dco-founder
Every character that isn't safe inside a single URL component — the space, the =, and the & — gets percent-encoded, which is exactly what you want before dropping a value into a query string so it doesn't get read as a second parameter.
Example: HTML entities encode
With HTML entities and Encode selected, this input:
<a href="/go?x=1&y=2">O'Malley & Sons</a>
produces:
<a href="/go?x=1&y=2">O'Malley & Sons</a>
That turns a string containing real markup into plain text that a browser will display literally — <, >, ", ', and & are the five characters that can otherwise be misread as the start of a tag, an attribute boundary, or another entity.
Which mode do you need?
| Mode | Encode turns this into that | Typical use |
|---|---|---|
| Base64 | Arbitrary text/bytes → A–Z, a–z, 0–9, +, /, = |
API tokens, data URIs, Basic Auth headers, email attachments |
| URL | Reserved/unsafe characters → %XX sequences |
Values going into a query string, path segment, or full URL |
| HTML entities | & < > " ' → & < > " ' |
User-generated text displayed inside HTML without executing as markup |
Tips and common mistakes
- Base64 decode is strict. It rejects input that isn't valid Base64 or that doesn't decode to valid UTF-8 text, and shows "Could not decode: input is not valid Base64" instead of guessing — so if you get that error, check for truncated or mixed-in text first.
- URL decode treats
+as a space. That matches how+is traditionally used in query strings, but if your encoded value should contain a literal+, decode it and check the result carefully. - The two URL directions aren't quite mirror images of plain
%20encoding. This tool's URL mode usesencodeURIComponent/decodeURIComponent, which is the right choice for a single query value — it escapes&,=,?, and/too, so don't use it to encode a value that should keep those characters (like a full URL you're embedding as-is). - HTML decode handles far more than the five escaped characters. Typing in things like
or©and decoding will convert them correctly, since decoding runs through the browser's own HTML parser rather than a small lookup table. - Nothing is uploaded. Encoding and decoding both run in your browser. Signed-out visitors have nothing saved; if you're signed in, your input syncs privately to your account.
Related tools
- URL Parser — break a full URL into protocol, host, path, and query parameters after you've encoded or decoded a piece of it.
- JSON Formatter — validate and pretty-print a JSON payload that contains Base64 or URL-encoded fields.
- Image to Base64 — encode an image file as a Base64 data URI instead of text.
- Hash Generator — compute an MD5 or SHA hash of a Base64 or URL-encoded string.
Frequently asked questions
Is Base64 encoding the same as encryption?
No. Base64 is a reversible text encoding, not encryption — anyone can decode it back to the original text with no password or key. It's used to make binary-ish data safe to put in text formats, not to keep it secret.
Why did my Base64 decode fail?
The decoder is strict: it rejects strings that aren't valid Base64 and strings that decode to bytes that aren't valid UTF-8 text, showing an error instead of mangled output. Double-check you copied the full string, including any trailing = padding.
What's the difference between the URL and HTML entities modes?
URL mode percent-encodes characters so text can safely be part of a URL (query string, path segment). HTML entities mode escapes characters so text can safely be displayed inside an HTML page without being parsed as markup. They solve different problems and produce different output for the same input.
Does URL encoding turn spaces into + or %20?
Encoding always produces %20 for a space. Decoding, however, treats a + in the input as a space before percent-decoding, matching how + is traditionally used for spaces in query strings.
Can this tool encode emoji and accented characters correctly?
Yes, in Base64 mode. It encodes the UTF-8 bytes of your text rather than raw character codes, so emoji, accented letters, and other non-ASCII characters encode and decode back to the exact original text.
More guides
- How to Convert Markdown to HTML (and Back) OnlineConvert Markdown to HTML or HTML back to Markdown with a live rendered preview, using the HTML ⇄ Markdown tool — no server, no account needed.
- How to Convert JSON to XML (With Custom Tag Names)Use the JSON to XML tool to turn JSON into well-formed XML — set a root and item tag, toggle the XML declaration, and choose 2, 4, or tab indent.
- How to Convert XML to JSON OnlineUse the XML to JSON converter to turn XML documents into JSON, with attributes becoming @keys and repeated tags becoming arrays automatically.