URLEncoder.tools is a free online URL encoder and decoder that converts special characters in URLs to their percent-encoded equivalents as defined by RFC 3986. It supports five encoding modes: Standard URL Encode (encodeURIComponent), Full URL Encode (encodeURI), URL Decode, Batch Mode for multiple URLs, and Form Data Encode. All processing happens client-side in the browser with zero data sent to any server. The tool supports 12 languages and works with Unicode characters including emoji.

免费在线 URL 编码与解码工具

即时编码或解码任何 URL 字符串 — 符合 RFC 3986 标准,在浏览器中运行,不向服务器发送数据。

100% 客户端处理无需登录符合 GDPR
字符数: 0编码序列: 0

提示:按 Ctrl+Enter 编码,按 Esc 清除

相关工具

什么是 URL 编码?

URL encoding (also called percent-encoding) is a method of converting special characters in a URL into a format that can be safely transmitted over the internet. It replaces unsafe ASCII characters with a percent sign (%) followed by two hexadecimal digits representing the character's byte value, as defined by RFC 3986.

For example, a space character becomes %20, an ampersand (&) becomes %26, and a question mark (?) becomes %3F. The unreserved characters that do not require encoding are: A-Z, a-z, 0-9, hyphen (-), underscore (_), period (.), and tilde (~).

URL 编码是如何工作的?

URL encoding works by converting each character to its UTF-8 byte sequence, then representing each byte as a percent sign followed by two hexadecimal digits. Single-byte ASCII characters like a space produce one percent-encoded triplet (%20), while multi-byte Unicode characters produce multiple triplets.

RFC 3986 divides characters into two groups: reserved characters (: / ? # [ ] @ ! $ & ' ( ) * + , ; =) that have special meaning in URL syntax, and unreserved characters (A-Z, a-z, 0-9, -, _, ., ~) that can appear in URLs without encoding. Reserved characters must be percent-encoded when used as data rather than as delimiters.

什么时候需要对 URL 进行编码?

当 URL 包含空格、和号 (&)、等号 (=) 或非 ASCII 字符等特殊字符时,您需要对 URL 进行编码。常见场景包括:为 API 调用构建查询字符串、编码表单数据以便提交、在电子邮件或消息中分享包含特殊字符的 URL,以及处理国际化域名。

Query Strings & API Calls

When building REST API requests, query parameters containing special characters like &, =, or spaces must be percent-encoded to avoid breaking the URL structure.

Form Data Submission

HTML forms submitted via GET method encode field values as query parameters. Spaces become + or %20, and special characters are percent-encoded.

Email & Messaging Links

URLs shared in emails or chat messages often contain special characters that need encoding to remain clickable and functional.

JavaScript fetch() & AJAX

When constructing URLs dynamically in JavaScript, always use encodeURIComponent() for parameter values to prevent XSS and malformed requests.

常见的 URL 编码字符

CharacterEncodedUnicode
(space)%20U+0020
!%21U+0021
#%23U+0023
$%24U+0024
&%26U+0026
+%2BU+002B
,%2CU+002C
/%2FU+002F
:%3AU+003A
;%3BU+003B
=%3DU+003D
?%3FU+003F
@%40U+0040
[%5BU+005B
]%5DU+005D

各编程语言中的 URL 编码

JavaScript

encodeURIComponent('hello world')
// → "hello%20world"

decodeURIComponent('hello%20world')
// → "hello world"

encodeURI('https://example.com/search?q=hello world')
// → "https://example.com/search?q=hello%20world"

Python

from urllib.parse import quote, unquote

quote('hello world')
# → "hello%20world"

unquote('hello%20world')
# → "hello world"

PHP

urlencode('hello world');
// → "hello+world"

rawurlencode('hello world');
// → "hello%20world"

urldecode('hello%20world');
// → "hello world"

Java

URLEncoder.encode("hello world", "UTF-8");
// → "hello+world"

URLDecoder.decode("hello+world", "UTF-8");
// → "hello world"

C#

Uri.EscapeDataString("hello world");
// → "hello%20world"

Uri.UnescapeDataString("hello%20world");
// → "hello world"

Ruby

require 'uri'

URI.encode_www_form_component('hello world')
# → "hello+world"

URI.decode_www_form_component('hello+world')
# → "hello world"

常见问题

哪些字符需要进行 URL 编码?

需要 URL 编码的字符包括空格、特殊字符(如 &、=、?、#、%)以及所有非 ASCII 字符。不需要编码的非保留字符为:A-Z、a-z、0-9、连字符 (-)、下划线 (_)、句点 (.)、波浪号 (~)。

URL 中 %20 和 + 有什么区别?

%20 表示 URL 路径中的空格,是标准的百分比编码。+ 号仅在使用 application/x-www-form-urlencoded 格式时在查询字符串参数中表示空格。

URL 编码和 Base64 编码是一样的吗?

不是。URL 编码将 URL 中的特殊字符转换为 %XX 十六进制格式。Base64 编码将二进制数据转换为使用 64 个可打印 ASCII 字符的文本字符串。它们用途完全不同。

如何在 JavaScript 中解码 URL?

使用 decodeURIComponent() 解码 URL 组件,或使用 decodeURI() 解码完整 URL。例如:decodeURIComponent('%20') 返回一个空格字符。

什么是 RFC 3986?

RFC 3986 是定义统一资源标识符 (URI) 语法的标准。它指定了 URL 中允许哪些字符,以及特殊字符应如何进行百分比编码。

为什么我的 URL 中有 %3D 和 %26?

%3D 是等号 (=) 的 URL 编码形式,%26 是和号 (&) 的编码形式。这些字符在 URL 中有特殊含义,因此当它们作为数据值使用时必须进行编码。

了解更多关于 URL 编码的信息

阅读我们关于 URL 编码最佳实践的深入指南和教程。

访问我们的博客