An online tool, a plain-English explanation and copy-ready code examples for percent (%XX) encoding with the browser's own encodeURIComponent / encodeURI / decodeURIComponent. Everything runs in your browser.
Type below and the three boxes underneath update live with the result of each of JavaScript's three native functions.

// encode a value so it can be used as a query parameter
const q = encodeURIComponent('café & tea');
// → "caf%C3%A9%20%26%20tea"
const url = 'https://example.com/search?q=' + q;
function buildQuery(params) {
return Object.keys(params)
.map(k => encodeURIComponent(k) + '=' + encodeURIComponent(params[k]))
.join('&');
}
const qs = buildQuery({ q: 'café', page: 2 });
// → "q=caf%C3%A9&page=2"
// in a browser: decoded for you automatically
const params = new URLSearchParams(window.location.search);
const q = params.get('q'); // already the decoded original text
// decoding an encoded string by hand
const raw = 'caf%C3%A9';
const text = decodeURIComponent(raw); // "café"
function encodeUrl(url) {
const u = new URL(url);
u.pathname = u.pathname.split('/').map(encodeURIComponent).join('/');
u.search = '?' + new URLSearchParams(
[...new URLSearchParams(u.search)].map(
([k, v]) => [encodeURIComponent(k), encodeURIComponent(v)]
)
).toString();
return u.toString();
}
encodeUrl('https://example.com/café?q=café');
function safeEncode(str) {
// if it already contains %XX, decode first so that we only encode once
const decoded = /%[0-9A-Fa-f]{2}/.test(str) ? decodeURIComponent(str) : str;
return encodeURIComponent(decoded);
}
encodeURIComponent() intentionally leaves a small set of punctuation characters, including the apostrophe, unescaped. If a receiver requires strict RFC 3986 percent-encoding for one component, encode those remaining characters after calling it:
function encodeStrictComponent(value) {
return encodeURIComponent(value).replace(/[!'()*]/g, char =>
"%" + char.charCodeAt(0).toString(16).toUpperCase()
);
}
encodeStrictComponent("O'Reilly"); // "O%27Reilly"Apply this to one query value or path segment, not to the complete URL. See the MDN encodeURIComponent reference and RFC 3986 reserved characters. If the value is going into HTML, JavaScript source, or a shell command, that output context may require its own escaping too; URL encoding does not replace context-specific escaping.
No sign-up · Unlimited use · Runs only in your browser. Want the general-purpose encoder instead? Go here →
Compare the two JavaScript URL encoders and learn when to encode one value or preserve a complete URL.
Every tool on this site runs entirely in your browser. Pick the encoding problem you have:
Getting URIError before a request is sent? Find lone surrogates and compare rejection with replacement.
Same-looking text producing different percent escapes? Compare Unicode NFC and NFD URL bytes before normalizing a value.
Working with repeated names? Compare ordered query pairs with scalar reads and object conversion before a value disappears.
Does an encoded dot change your route? Inspect dot-segment parsing and compare the actual request target.