---
title: "URL Encoder and Decoder | ToolSugar"
description: "Percent-encode or decode text with encodeURIComponent or encodeURI. Bad input gets a readable error. It runs in your browser."
canonical: https://toolsugar.com/tools/url-encoder
image: https://toolsugar.com/og.png
---

# URL Encoder and Decoder

This URL encoder converts text to percent-encoding and back, using either encodeURIComponent for a single value or encodeURI for a whole address. If the text you try to decode is malformed, such as a stray percent sign, it explains the problem instead of failing silently. It runs in your browser.

Runs on your device

## How it works

1. Choose Encode or Decode.
2. Choose encodeURIComponent for one value or encodeURI for a complete URL.
3. Type or paste your text into the input box.
4. Read the Result and press Copy.

## Key facts

- **Modes**: encodeURIComponent and encodeURI, plus the matching decoders
- **Character set**: Non-ASCII characters are encoded as UTF-8 bytes
- **Errors**: Malformed percent escapes produce a readable message
- **Where it runs**: In your browser, with no upload

## Common uses

- Build a safe query-string value that contains spaces, ampersands or accents.
- Decode a long percent-encoded link from a log to read it.
- Check what encodeURI would leave alone in a full address.

## Questions

### What is the difference between encodeURI and encodeURIComponent?

encodeURIComponent escapes reserved characters such as / ? & and =, so it suits one query value. encodeURI leaves them as they are, so it suits a whole URL that is already structured.

### Why does decoding fail with a percent sign error?

Percent-encoding needs a % followed by two hex digits. A lone % or an escape that is not valid UTF-8 cannot be decoded, and the tool tells you so.

### Is a space encoded as %20 or a plus sign?

These functions encode a space as %20. A plus sign for a space belongs to HTML form encoding, which this tool does not apply.

[Read the URL Encoder and Decoder guide](https://toolsugar.com/blog/how-to-url-encode-a-string)

## Related tools

- [Base64 Encoder and Decoder](https://toolsugar.com/tools/base64-encoder)
- [QR Code Generator](https://toolsugar.com/tools/qr-code-generator)
- [Diff Checker](https://toolsugar.com/tools/diff-checker)
