JSON 圧縮
JSONから不要な空白を削除して圧縮。
JSON 圧縮とは
JSON圧縮(ミニファイ)とは、JSONから改行や空白を取り除いてデータサイズを小さくする処理です。転送量の削減に使われます。
🔒 処理はすべてブラウザ内で完結し、データは送信されません。
このツールの前提
- 処理場所
- このページのブラウザ内(JavaScript / Canvas)
- アップロード
- なし — ファイルは端末の外に出ません
- オフライン
- ページを開いた後は通信不要
Removing whitespace without touching strings
Whitespace outside string literals is insignificant in JSON, so it can be dropped entirely. The subtle part is that whitespace inside strings is data: "hello world" must keep both spaces. A minifier that runs a regex over the raw text breaks such values, and the damage only shows up later when a field no longer matches.
This implementation tokenises properly — strings and escapes are tracked — so only structural whitespace is removed. The output is byte-different and semantically identical, which is what makes it safe to minify as a build step.
What minifying does not buy you
With gzip or brotli in front of it, minified JSON is typically only a few percent smaller on the wire, because the compressor already removes the repeated spaces. The real benefit is on parse time and on payloads that travel without compression — a webhook body, a Redis value, an embedded config.
Minifying also destroys readability, diffs and review. Keep the formatted source in version control and minify at build or at send time; minified JSON committed to a repository makes every future change unreviewable.
The failure that looks like success
If the input is not valid JSON, a tolerant minifier can still produce output that looks plausible while having removed something it should have kept — inside a broken string, whitespace is ambiguous. Always parse the result before shipping it: a one-line JSON.parse check catches the whole class of problem.
Copy-paste damage is the usual cause here too. A curly quote or a non-breaking space pasted from a document is not structural whitespace in the JSON sense, and depending on the tokeniser it either survives into the output or breaks the value. Escaping it explicitly is the reliable fix.
使い方
- 1.JSONを貼り付け
- 2.「圧縮する」をクリック
- 3.結果をコピー
他の方法との比較
同じ変換をする方法は 3 つあります。ブラウザ内(このページ)、サーバー側の変換サービス、デスクトップアプリ。差がつくのは速度ではなく、ファイルがどこへ行くかと、無料でどこまでできるかです。
| 観点 | このツール | サーバー側の変換サービス | デスクトップアプリ |
|---|---|---|---|
| ファイルの処理場所 | このページのブラウザ内 | ベンダーのサーバー(アップロード後) | 自分の PC(アプリをインストール) |
| アカウント | 不要 | 多くの場合必要(無料枠の制限解除に登録を求める) | 不要(ライセンス認証は必要な場合あり) |
| 無料で扱えるサイズ | サイズ制限なし(回数制限もなし) | 数ファイル/時間、または 5〜10MB 程度で課金 wall | ディスクとメモリ次第 |
| 料金 | 無料。Pro は月 $9(大きいファイルと AI 機能のみ) | サブスクが一般的。おおむね月 $7〜15(2026 年 11 月時点) | 買い切り、またはサブスク |
| オフライン | 一度開けば通信不要 | 不可 | 可 |
| 20MB を処理し始めるまで | 待ち時間なし(アップロードが無い) | アップロードが支配的(10Mbps 上りで約 16 秒) | アプリの起動のみ |
| 保証できないこと | 不正な入力は「修復」せず、パーサのエラー位置を返します | 同じ(変換の原理は変わらない) | 同じ。ただし書式の再現はより忠実な場合がある |
サーバー側のサービスが優れている点は明確にあります。巨大なファイル、チームでの共有、変換履歴の管理、スクリプトからの自動化。逆に「1 回だけ、手元のファイルを別形式にしたい」という今回の用途では、アップロードの待ち時間と登録の手間だけが増えます。
よくある質問
JSON圧縮とは?
空白や改行を削除してファイルサイズを小さくします。
内容は変わりますか?
データの意味は変わりません。見た目の空白がなくなるだけです。
この変換で失われるもの
フォーマッタは入力を構文木に解析し、一貫したインデントで出力します。入力が不正なら、黙って壊れたファイルを返すのではなく、パーサのエラー位置を表示します。壊れた JSON は「修復」されず、そのまま壊れたまま示されます。