エンコード
URL Encode/Decode
URL エンコード・デコード — リンクやクエリパラメータでエスケープが必要な文字を変換します。
URL encoding (percent-encoding) replaces characters that aren't allowed in a URL — spaces, non-Latin letters, special characters — with %XX sequences, where XX is the hex code of the byte. This keeps links and query parameters from getting mangled in transit.
How to use it
- Encode: paste text or a URL and any character outside the safe ASCII set is replaced with a %XX sequence.
- Decode: paste an encoded string to see the original text.
- Encoding a full URL and encoding a single query parameter use slightly different safe-character sets — pick the mode that matches what you're encoding.
Common uses
- Building query parameters from text containing spaces, ampersands, or non-Latin characters.
- Debugging why a link with a parameter breaks — often the cause is an unencoded special character.
- Decoding URLs from third-party systems to read them in their original form.
Things to keep in mind
Encode parameter values, not the whole URL at once — otherwise you'll also encode the separators you need (:, /, ?, &).
JavaScript's encodeURIComponent and encodeURI encode different character sets — the former is meant specifically for parameter values.
よくある質問
URL エンコードとは何ですか?
URLで特別な意味を持つ文字(スペースや &、日本語などの非ASCII文字)を %XX 形式のパーセントエンコーディングに変換する方式です。クエリパラメータやパス内で文字化けや意図しない解釈を防ぐために使います。
コンポーネントと URI の違いは何ですか?
コンポーネントモードはクエリパラメータの値など単一の断片を想定し、&や=も含めてエンコードします。URIモードはURL全体を想定し、:や/など構造上必要な文字はそのまま残します。
URL エンコードと URL セーフ Base64 は同じものですか?
異なります。URLエンコードは文字を%XX形式に変換するパーセントエンコーディングで、URLセーフBase64はBase64の+と/を-と_に置き換えただけのものです。混同しやすいので用途に応じて使い分けてください。
二重エンコードとは何ですか、どう見分けますか?
すでにエンコードされた文字列をもう一度エンコードしてしまう間違いです。%自体が%25に変換されるため、%20は%2520になります。デコード結果に%25XXのようなパターンが現れたら、二重エンコードの兆候です。
スペースが + でエンコードされる場合と %20 でエンコードされる場合があるのはなぜですか?
スペースを+で表すのは、フォームやクエリ文字列で使われるapplication/x-www-form-urlencoded形式です。%20はRFC 3986で定義された標準のパーセントエンコーディングで、URLのどの部分でも正しく使えます。