LocalExcelTool
はじめる

エスケープ / アンエスケープ

HTML / XML / JSON / JS の文字列をエスケープ・復元します。

エスケープ / アンエスケープとは

エスケープツールは、HTML・XML・JSON・JavaScriptの4形式に対応した文字列の変換・復元ツールです。特殊文字(< > & " ' 改行など)を安全な形式に変換し、逆にエスケープ済み文字列を元に戻せます。コードへの埋め込みやログの調査に使われます。

🔒 処理はすべてブラウザ内で完結し、データは送信されません。

このツールの前提

処理場所
このページのブラウザ内(JavaScript / Canvas)
アップロード
なし — ファイルは端末の外に出ません
オフライン
ページを開いた後は通信不要

A dead Netscape function, kept alive by legacy data

escape() produces %uXXXX for characters above U+00FF and %XX for those below. That is a different scheme from encodeURIComponent, which always emits the UTF-8 bytes as %XX. One Chinese character becomes one %uXXXX under escape and three %XX sequences under percent-encoding.

The function was deprecated because it cannot represent non-BMP characters properly and because %uXXXX is not a valid URI escape — no standard parser outside JavaScript understands it. unescape() is its inverse and equally deprecated. Both still exist because decades of bookmarks, cookies and log lines contain their output.

Why the mismatch bites

Bookmarks and cookies written by old browsers contain %u escapes; modern URL parsers pass them through untouched, so the value arrives at the server still encoded. Servers that decode only standard percent-encoding then store the literal string %u4e2d, and a later round trip double-encodes it. That is the origin of the mojibake chains people describe as 'broken Chinese in old links'.

The reverse mistake is applying unescape() to standard percent-encoding. It handles %XX, but it decodes each byte as a Latin-1 character rather than assembling UTF-8, so a three-byte CJK character becomes three mojibake characters instead of one correct one.

The replacement that does the same job

For anything new, use encodeURIComponent / decodeURIComponent and keep the payload in UTF-8. It is standard, it round-trips through every language, and it matches what browsers put on the wire.

Only reach for %u handling when the data already contains it. In that case treat the conversion as a migration step — convert once, store the result, and stop generating new %u escapes, because every legacy escape left in a system has to be explained to the next person who touches it.

使い方

  1. 1.形式(HTML/XML/JSON/JS)を選択
  2. 2.方向(エスケープ/復元)を選択
  3. 3.テキストを入力して実行

他の方法との比較

同じ変換をする方法は 3 つあります。ブラウザ内(このページ)、サーバー側の変換サービス、デスクトップアプリ。差がつくのは速度ではなく、ファイルがどこへ行くかと、無料でどこまでできるかです。

観点このツールサーバー側の変換サービス
ファイルの処理場所このページのブラウザ内ベンダーのサーバー(アップロード後)
アカウント不要多くの場合必要(無料枠の制限解除に登録を求める)
無料で扱えるサイズサイズ制限なし(回数制限もなし)数ファイル/時間、または 5〜10MB 程度で課金 wall
料金無料。Pro は月 $9(大きいファイルと AI 機能のみ)サブスクが一般的。おおむね月 $7〜15(2026 年 11 月時点)
オフライン一度開けば通信不要不可
20MB を処理し始めるまで待ち時間なし(アップロードが無い)アップロードが支配的(10Mbps 上りで約 16 秒)
保証できないこと出力は決定的です。他の実装と突き合わせて検証できます同じ(変換の原理は変わらない)

サーバー側のサービスが優れている点は明確にあります。巨大なファイル、チームでの共有、変換履歴の管理、スクリプトからの自動化。逆に「1 回だけ、手元のファイルを別形式にしたい」という今回の用途では、アップロードの待ち時間と登録の手間だけが増えます。

よくある質問

HTMLとXMLの違いは?

両方とも< > & "を変換しますが、XMLは単引用符を&apos;に、HTMLは&#39;に変換します。

JSONエスケープの対象は?

バックスラッシュ、ダブルクォート、改行・タブなどの制御文字を\"、\n、\tの形式に変換します。

この変換で失われるもの

エンコードとハッシュは Web Crypto API または純 JavaScript 実装で行います。出力は決定的で、同じ入力からは常に同じ結果になります。他のツールと突き合わせて検証できます。

その他のエンコード / デコード