テキスト
CRLF ↔ LF Converter
Windows(CRLF)、Unix/macOS(LF)、クラシックMac(CR)の間で改行コードを変換。混在した改行の検出にも対応。
ブラウザはフィールドに貼り付けられたテキストを自動的にLFに正規化するため、元のCRLF/CRをここで検出することはできません — 実際のCRLF/CRを含むファイルを解析・変換するには、上のファイルアップロードを使用してください。
Windows, Unix/macOS, and the old classic Mac historically use different characters to mark the end of a line — CRLF, LF, and CR respectively. Mixing these styles in one file often causes odd artifacts in diffs or editors. This tool converts line endings to one style and detects mixed ones.
How to use it
- Paste text and the tool automatically detects the current line-ending style, including a mixed one.
- Pick a target format (CRLF, LF, or CR) and the conversion happens instantly.
- If several styles are found in the same file, that's flagged with a separate warning.
Common uses
- Fixing a file where git diff shows every line as changed because of differing line endings, even though the content itself didn't actually change.
- Converting a text file to the format a specific system or script expects (a Unix script, for instance, expects LF).
- Debugging why a file opened in a Windows editor shows the entire text on one line (a sign of plain LF with no CR).
Things to keep in mind
Git can automate this conversion itself through core.autocrlf or .gitattributes — often more convenient than converting files in a repository by hand.
Mixed line endings in one file aren't always visible at a glance, but they can break parsers or scripts that expect one specific style.
よくある質問
なぜ改行はシステムによって異なるのですか?
WindowsはCRLF(\r\n)を使用し、UnixとmacOSはLF(\n)のみを使用し、クラシックMacはCR(\r)のみを使用していました — これらの異なる歴史的慣習が、ファイルがシステム間を移動する際に不整合を引き起こします。
なぜテキストを貼り付ける代わりにファイルをアップロードする必要があるのですか?
ブラウザは入力フィールドに貼り付けられたテキストを自動的にLFに正規化するため、実際の元のCRLFやCR文字は貼り付けた時点で検出不能になります — 分析や変換のために実際の改行を保持するのは直接のファイルアップロードだけです。
この種の問題は実際にいつ重要になりますか?
特に重要なのは、git(改行によるノイズの多い差分)、残ったCRLFで失敗するシェルスクリプト、WindowsとUnix/macOSシステム間でやり取りされるファイルです。アップロードされたファイルはブラウザ内でのみローカルに処理され、サーバーに送信されることはありません。
ファイル内にCRLFとLFが混在している場合はどうすればいいですか?
複数のエディタや異なるOSで編集されたファイルには、両方のスタイルが同時に含まれていることがあります。変換は目に見えて「怪しい」行だけでなく、ファイル全体に適用する必要があります — そうしないと、問題のある改行の一部が気づかれないまま残ってしまいます。
gitで変換を自動化できますか?
はい、gitの<code>core.autocrlf</code>設定はcheckoutとcommit時に改行を自動的に変換し、<code>.gitattributes</code>を使えばリポジトリ内の特定のファイル種別に対して改行スタイルを明示的に指定できます。