What is URL encoding and decoding?
URL encoding is a way to represent bytes and reserved characters safely inside URI strings. It matters whenever a value needs to move through a path, query string, redirect target, callback parameter, or any other place where visible characters also carry syntax meaning.
How percent-encoding works
A text value is first turned into bytes, usually UTF-8 bytes in modern web tooling. Bytes that cannot safely stay visible in the target URL context are then written as hexadecimal `%HH` sequences.
- Letters, digits, hyphen, underscore, period, and tilde usually remain readable as unreserved characters.
- Characters such as space, ampersand, question mark, equals sign, slash, or non-ASCII text often need encoding because they either break syntax or become ambiguous.
- Form-style encoding sometimes writes spaces as `+`, while generic URI encoding prefers `%20`, so not every encoded string is interchangeable.
このツールの使い方
- Decide whether you are working with a full URL, a path fragment, or a single query-parameter value before you start.
- Encode or decode the sample text, then verify spaces, reserved characters, and UTF-8 content in the result.
- Reuse the result only after you confirm that the conversion direction and the target URL context both match your workflow.
URL エンコード・デコード の例
この例は、URL エンコード・デコード が想定している入力の形と、自分の作業に使う前に確認しておきたい結果の見え方を示しています。
入力例
https://codertools.site/search?q=json formatter&lang=en
期待される出力
https%3A%2F%2Fcodertools.site%2Fsearch%3Fq%3Djson%20formatter%26lang%3DenClassic encoding example
Original value:
https://example.com/search?q=json formatter&lang=zh-CN
Encoded value:
https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Djson%20formatter%26lang%3Dzh-CNよくある使い方
URL エンコード・デコード は、ブラウザを離れずに短く反復的な作業をすばやく片づけたい場面向けに設計されています。
- ドキュメント、チケット、リリースノートを書きながら小さな値を素早く確認する。
- チームメンバーや顧客へ共有する前に、コピーした内容を整える。
- 表計算、IDE、デスクトップアプリを開かず、同じ変換を繰り返す。
Where URL Encoding Goes Wrong in Practice
Most URL-encoding issues come from applying the right operation in the wrong place: encoding a full URL when only a parameter should be encoded, decoding an already-normal value, or mixing browser, backend, and form conventions.
- Decide first whether you are encoding a full URL, a path segment, or a single parameter value.
- Keep raw and encoded samples side by side when debugging callbacks, redirect chains, or third-party query parameters.
- Treat browser output as context-specific text, not as a universal representation that every downstream system will interpret the same way.
When to encode the full URL and when to encode only a value
This is where many production bugs come from. If you are building a query string manually, you usually encode the parameter value, not the entire already-structured URL shell.
- Encode an entire URL when you need to place that URL as data inside another parameter or redirect field.
- Encode only the value when you are filling a query parameter, search keyword, callback token, or user-provided path fragment.
- Repeated decoding is dangerous because a once-correct string may lose literal percent signs or become malformed.
URL encoding compared with nearby formats
| Format | What it does | Typical use |
|---|---|---|
| URL encoding | Escapes bytes inside URI contexts | Query parameters, redirect targets, path segments |
| Base64 | Turns binary bytes into printable text | Token parts, Data URI payloads, text-safe transport |
| HTML entities | Escapes HTML-sensitive characters | Template output, rich text, markup embedding |
実用上の注意
- URL エンコード・デコード は既定でブラウザ内で動作するため、別のツールチェーンを用意せずにすばやくローカル確認を行えます。
- 実際の入力が大きい、機密性が高い、または業務上重要な場合は、まず代表的なサンプルから始めてください。
- 本番環境、顧客向け、法務、財務、安全性が重要な作業に使う前に、最終結果を必ず確認してください。
URL エンコード・デコード の参考情報
URL エンコード・デコード は、パーセントエンコーディング、安全な URL 伝送、バイトと見た目の文字の違いを説明します。
- URL エンコードでは通常、テキストを UTF-8 バイトに変換し、予約または安全でないバイトを `%HH` の 16 進表記で出力します。
- 英字、数字、ハイフン、アンダースコア、ピリオド、チルダなどの非予約文字は、そのまま読める形で残せます。
- デコードでは `%HH` シーケンスをバイトへ戻し、通常は UTF-8 など期待される文字セットで解釈します。
参考資料
FAQ
URL エンコード・デコード の用途と、入力・出力・結果に関するよくある疑問をまとめています。URL の各部分を安全にエンコードし、エスケープ済み URL をデコードします。
Should I encode a full URL or only one component in URL エンコード・デコード?
Most of the time you should encode only the component that needs escaping, such as a query parameter or callback value. Encoding an already complete URL blindly can make it harder to read or reuse.
Why do spaces from URL エンコード・デコード become %20 instead of +?
Percent encoding and form encoding are related but not identical. `%20` is the safer general URL representation, while `+` is often used specifically in form-style query encoding.
Why can repeated decoding in URL エンコード・デコード break a link?
Double decoding can turn reserved characters back into literal separators, which may change query boundaries or route segments. Decode only when you know the current string is still encoded.
What kind of query parameters, path fragments, callback URLs, copied links, and percent-encoded text is URL エンコード・デコード best suited for?
URL エンコード・デコード is built to encode URL components or decode percent-encoded strings. It is most useful when query parameters, path fragments, callback URLs, copied links, and percent-encoded text must become URL-safe text or readable decoded characters for OAuth callback checks, search-parameter debugging, link cleanup, analytics URLs, and copied API examples.
What should I review in the URL-safe text or readable decoded characters before I reuse it?
Review reserved characters, spaces, UTF-8 bytes, double encoding, and whether a full URL or only one component is being processed first. Those details are the fastest way to tell whether the result is actually ready for downstream reuse.
Where does the URL-safe text or readable decoded characters from URL エンコード・デコード usually go next?
A typical next step is OAuth callback checks, search-parameter debugging, link cleanup, analytics URLs, and copied API examples. The output is written to be reused there directly instead of acting like a generic placeholder.
When should I stop and manually double-check the result from URL エンコード・デコード?
Do not blindly decode unknown URLs multiple times because double decoding can change reserved characters and break links.