テキスト
Whitespace & Trim Tools
余分な空白を整理:行端の空白をトリム、連続する空白をまとめる、空行を削除、タブ↔スペースを変換。
Extra whitespace — at line edges, doubled up inside text, blank lines, mixed tabs and spaces — is rarely visible at a glance, but it often breaks string comparisons, parsing, or how code looks. This tool cleans up such issues with a set of targeted operations.
How to use it
- Trim: strip whitespace from the start and end of every line.
- Collapse: replace several consecutive spaces or blank lines with a single one.
- Tabs ↔ spaces: convert in either direction with a chosen number of spaces per tab.
Common uses
- Cleaning up text copied from a PDF or Word document, which often leaves extra spaces and invisible characters behind.
- Normalizing code indentation to one consistent style (spaces only or tabs only) before a commit.
- Debugging why two visually identical lines aren't equal when compared — often the cause is a hidden extra space or a non-breaking space.
Things to keep in mind
A non-breaking space ( , code point U+00A0) looks like a regular space but is a different character to a computer — strings containing it aren't equal to a regular space in comparisons.
Trimming line-edge whitespace doesn't touch spaces inside words or sentences — collapsing repeated internal spaces is a separate operation.
よくある質問
端のトリミングと繰り返しスペースの圧縮の違いは何ですか?
端のトリミングは各行の先頭と末尾のスペースのみを削除しますが、繰り返しスペースの圧縮は行内の複数の連続するスペースを1つに置き換え、端には触れません。
空行とタブ/スペース変換はどのように処理されますか?
空行を完全に削除するか、連続する空行を1つに圧縮するかを選択でき、設定可能なタブ幅でタブをスペースに、またはその逆に変換できます。
貼り付けたテキストはサーバーに送信されますか?
いいえ、クリーンアップはブラウザ内で完全にJavaScriptで行われ、データはどこにも送信されません。
幅ゼロ文字とは何ですか?
これは(zero-width space、zero-width joinerなど)画面上でまったくスペースを取らないものの、テキスト内には独立した文字として存在する文字です。一部のサイトからコピーする際にテキストに紛れ込むことがあり、文字列比較や検索を気づかれずに壊すことがあります。
なぜノーブレークスペースは通常のスペースに見えても違う挙動をするのですか?
ノーブレークスペース( )は見た目には通常のスペースと同じですが、コンピュータにとっては別の文字です。この2種類のスペースを含む文字列は、画面上では同じに見えても、比較すると技術的には等しくありません。