スタート サイトを登録

URL エンコード・デコード

Developer Tools

テキストをパーセントエンコードしたり元に戻したりできます。URL 全体とクエリ値の単位を切り替えて使い分けられます。

結果

結果 —
  • 入力文字数 —
  • 出力文字数 —
  • 出力バイト数 — B

入力値を変更すると、結果はすぐに更新されます。

計算式とルール

  • パーセントエンコーディングでは、許可されたセット外の各バイトを、パーセント記号と2桁の16進数で書き表します。
  • A space becomes %20, a slash becomes %2F, and the ampersand becomes %26 — the last one matters because & separates query parameters.
  • encodeURIは : / ? # & = をそのまま残すためリンクの構造が保たれますが、encodeURIComponentはこれらをエスケープします。
  • デコードは各%XXの3文字組を元のUTF-8バイトに戻すため、中国語のテキストは元の文字として復元されます。

計算例

クエリ文字列内の値

入力 値スコープでの a b&c。

結果 a%20b%26c — the & is escaped so it cannot be read as a second parameter.

同じテキストをURL全体として扱う場合

入力 URL全体スコープでの a b&c。

結果 a%20b&c — the space is still escaped but & is preserved as a separator.

中国語テキストのデコード

入力 %E4%BD%A0%E5%A5%BD

結果 你好 — 3つのUTF-8バイトが3つの%XXの3文字組になり、デコードで復元されます。

よくある質問

encodeURIではなくencodeURIComponentが必要なのはどんなときですか?

? や & の後に配置する値には必ず encodeURIComponent を使用してください。値の中のエスケープされていない & や = はクエリを分割してしまうからです。encodeURI は、区切り文字がすでに配置された完全なリンクにのみ使用してください。

Why does a space sometimes become + instead of %20?

The plus sign belongs to form encoding for application/x-www-form-urlencoded bodies, where it means a space. JavaScript URL functions write %20 instead. This tool reads + as a space when decoding and always writes %20 when encoding, so the two conventions do not collide.

Why do I see %25 in my links?

%25 is an encoded percent sign, which means the text was encoded twice. Encode once at the point where the value is inserted, not again when building the final link.

不完全な % シーケンスが含まれている場合はどうなりますか?

% の後には正確に 2 桁の 16 進数が続く必要があるため、デコードは失敗します。このツールは文字を黙って破棄するのではなく、問題を報告します。

免責事項: 結果は本ページ記載の計算式による参考値です。実際の必要量は材料・施工方法・環境によって変わるため、ご注文前に余裕を見てください。