Home › Developer Tools › Line Ending Converter

Line Ending Converter

Paste text or drop files to see which line endings they use, then convert them to LF, CRLF or CR in one click. Files are converted byte by byte in your browser, so UTF-8 text is never damaged and nothing is uploaded.

Last updated:

Convert to
Result preview (line endings shown as markers)

        

Browsers turn every line break you type into LF. Line endings in pasted text are kept exactly; to check a file byte for byte, use the Files tab.

Advertisement
Advertisement

How to use the Line Ending Converter

  1. Paste text or open the Files tab and drop one or more files (code, CSV, config, text).
  2. Check the detected line endings. The counters show how many CRLF, LF and CR breaks were found and warn when they are mixed.
  3. Choose the target: LF for Linux, macOS and Git repositories, CRLF for Windows tools, CR only for very old Mac software.
  4. Pick the extras you want: trim trailing whitespace, ensure a final newline, and keep, remove or add a BOM.
  5. Press Convert line endings, then copy the text or download each file with its original name (or all files as a ZIP).

Line endings at a glance

NameBytesEscapeUsed by
LF (line feed)0A\nLinux, macOS (OS X and later), Android, most programming languages, Git repositories
CRLF (carriage return + line feed)0D 0A\r\nWindows, MS-DOS, HTTP headers, SMTP email, many network protocols, CSV files from Excel
CR (carriage return)0D\rClassic Mac OS 9 and earlier, some old printers and devices

The names come from typewriters and teleprinters: a carriage return moved the print head back to the start of the line and a line feed advanced the paper. Windows kept both characters, Unix kept only the line feed, and classic Mac OS kept only the carriage return.

Where the wrong line ending causes trouble

  • Shell scripts: a script saved with CRLF fails with /bin/bash^M: bad interpreter or $'\r': command not found. Convert it to LF.
  • Git diffs: when an editor changes every ending, a diff shows every line as modified even though no content changed.
  • Docker and CI: entrypoint scripts and config files copied from Windows into Linux containers need LF.
  • Windows tools: old versions of Notepad and some batch files expect CRLF and may show LF files as one long line.
  • Protocols: HTTP/1.1 headers and SMTP email lines must end with CRLF by specification (RFC 9112 and RFC 5321).

Fix line endings for good in Git

Converting a file once helps, but a .gitattributes file at the root of the repository stops the problem from coming back. A common setup stores text with LF and lets Windows-only files keep CRLF:

* text=auto eol=lf
*.bat text eol=crlf
*.cmd text eol=crlf
*.png binary

After adding the file, run git add --renormalize . and commit to rewrite existing files. On the command line you can also use dos2unix file.txt and unix2dos file.txt, or sed -i 's/\r$//' file.txt to strip carriage returns.

How to see line endings in your editor

  • VS Code: the status bar shows LF or CRLF; click it to change the current file. The files.eol setting controls new files.
  • Notepad++: View › Show Symbol › Show End of Line, and Edit › EOL Conversion to convert.
  • Vim: :set ff? shows the format; :set ff=unix then :w converts to LF.
  • Terminal: file name.txt reports "with CRLF line terminators", and cat -A shows CR as ^M.

Frequently asked questions

What is the difference between CRLF and LF?

Both mark the end of a line. LF is a single line feed byte (0x0A) used by Linux, macOS and most programming tools. CRLF is a carriage return followed by a line feed (0x0D 0x0A) and is the Windows convention. CR alone (0x0D) was used by classic Mac OS before OS X.

Why does Git warn that LF will be replaced by CRLF?

Git can normalise line endings when you commit or check out files, controlled by core.autocrlf and .gitattributes. The warning means a file in your working copy uses a different ending than Git will store. Converting the file to LF before committing, or adding a rule such as * text=auto eol=lf to .gitattributes, makes the warning go away.

Will converting damage UTF-8 or special characters?

No. The bytes 0x0D and 0x0A never appear inside a multi-byte UTF-8 character, so the tool changes only the line-break bytes (and trailing spaces or tabs if you ask it to). Every other byte is copied exactly. UTF-16 files with a BOM are converted per 16-bit character for the same reason.

What are mixed line endings?

A file has mixed endings when some lines end with CRLF and others with LF or CR, which often happens after copying code between Windows and Unix editors. Mixed endings can break diffs, shell scripts and some parsers. Converting the whole file to one style fixes it.

Why can a shell script fail with '\r: command not found'?

The script was saved with Windows CRLF endings, so Bash sees an extra carriage return at the end of every line. Converting the script to LF fixes the error.

What does the BOM option do?

A byte order mark is an invisible marker at the start of a file. Some Windows programs add it to UTF-8 files, while many Unix tools and PHP or shell scripts do not expect it. Keep leaves it unchanged, Remove deletes it and Add puts a UTF-8 BOM at the start of UTF-8 text.

Are my files uploaded?

No. Files are read and converted with JavaScript in your browser and the results are saved straight from your device. Nothing is sent to a server.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Text Encoding ConverterDetect and convert text file encodings like UTF-8, UTF-16 and Latin-1.Remove Line BreaksStrip line breaks and extra spaces, keep paragraphs if you want.Text CompareFind the differences between two texts.Hash GeneratorGenerate MD5, SHA-1, SHA-256 and SHA-512 hashes of text or files.EditorConfig GeneratorBuild an .editorconfig with indent, charset, line endings and trim rules per file pattern.Gitignore GeneratorBuild a .gitignore from 50+ templates for languages, frameworks, IDEs and OS, merged and deduped.INI to JSON ConverterConvert INI and CFG files to JSON and JSON back to INI, with sections, arrays and types.Trim Characters from LinesRemove the first or last N characters, or text before/after a marker, on every line.JSON to Excel ConverterTurn JSON into a styled .xlsx spreadsheet; nested arrays become their own linked sheets.JSON to CSVConvert JSON data to CSV for spreadsheets.CSV to JSONConvert CSV data to JSON with live preview.Excel to CSVConvert XLSX spreadsheets to CSV.CSV ViewerOpen a CSV or TSV file as a sortable, filterable table.Excel Viewer (XLSX / XLS)Open XLSX, XLS and ODS spreadsheets in your browser without Excel.Markdown to HTMLConvert Markdown to clean HTML with a live editor.XML to JSONConvert XML to JSON with validation.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.TTF to WOFF2 ConverterConvert TTF and OTF fonts to WOFF2 or WOFF and get a ready @font-face CSS snippet.Chmod CalculatorConvert Linux file permissions between checkboxes, octal (755) and symbolic (rwxr-xr-x) notation.JSON to TypeScriptGenerate TypeScript interfaces or types from JSON, with nested types and optional fields.Morse Code TranslatorTranslate text to Morse code and back, then play it as sound or a blinking light, or save a WAV.HTML Table GeneratorBuild HTML tables in an editable grid with styles, header rows, CSV import and live preview.Hex to Text ConverterConvert hex to text and text to hex with UTF-8 support and space, 0x, \x or comma formats.JSON to XML ConverterConvert JSON to well-formed XML with attributes, arrays and pretty print.JSON to YAML ConverterConvert JSON to clean YAML as you type, with indent, quoting and sort options.YAML to JSON ConverterConvert YAML to pretty or minified JSON, with errors pinned to the exact line.HTML to Markdown ConverterTurn HTML or pasted rich text into clean Markdown with tables and live preview.Markdown Table GeneratorBuild Markdown tables in a grid or paste from Excel/CSV, with alignment and preview.JSON ValidatorCheck JSON with the exact line and column of each error, fix tips and one-click auto-fix.Image to Base64Convert images to Base64 data URIs, CSS backgrounds and HTML img tags in your browser.Base64 to ImagePaste a Base64 string or data URI to preview, identify and download the image.JSON CompareCompare two JSON documents and see every added, removed and changed path.Hex to DecimalConvert hex to decimal instantly with steps and signed mode.Decimal to HexConvert decimal to hex instantly with steps and signed mode.Binary to DecimalConvert binary to decimal instantly with steps and signed mode.Decimal to BinaryConvert decimal to binary instantly with steps and signed mode.Two's Complement CalculatorDecimal to two's complement binary and back for 4-64 bits, with invert-and-add-1 steps.XML to CSV ConverterConvert XML to CSV: detects repeating records, flattens nested data, pick your columns.KML ViewerOpen KML and KMZ files on an interactive map: placemarks, paths, polygons, folders, export.MySQL to PostgreSQL ConverterConvert MySQL dumps and CREATE TABLE statements to PostgreSQL: types, AUTO_INCREMENT, ENUMs, quotes.Text to CSV ConverterTurn space-aligned, fixed-width, pipe or tab separated text into clean CSV with a live preview.VCF File ViewerOpen vCard .vcf files as contact cards with photos, search and duplicate check, export CSV.XML ViewerBrowse XML as a collapsible tree with search, XPath of any node, attributes and big-file support.CSV to XML ConverterConvert CSV to well-formed XML with custom root and row names, escaping and pretty print.TOML to JSON ConverterConvert TOML to JSON and JSON to TOML with a full v1.0 parser and clear error lines.JSON to Go StructTurn JSON into Go structs with inferred types, nested structs and json tags.JSON to Python ClassGenerate Python dataclasses, Pydantic models or TypedDicts with type hints from JSON.JSON to C# ClassConvert JSON to C# classes or records with System.Text.Json or Newtonsoft attributes.JSON SorterSort JSON keys A-Z recursively, sort arrays by value or by a key, then pretty-print or minify.JSON to HTML TableConvert a JSON array of objects into clean HTML table code with CSS styles and a live preview.CSV to SQL ConverterConvert CSV to SQL CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server.IPv4 to IPv6 ConverterConvert IPv4 to IPv4-mapped, 6to4 and NAT64 IPv6, extract IPv4 from IPv6, and get int/hex/binary.cURL to Code ConverterConvert curl commands to JavaScript fetch, Axios, Python requests, Node.js, PHP and Go code.Code to ImageTurn code into a beautiful syntax-highlighted PNG with themes, window frame and background.Excel to JSON ConverterConvert Excel sheets (XLSX, XLS, ODS) to JSON with header row, type and shape options.CSV to Excel ConverterConvert CSV files to a real .xlsx workbook with typed numbers and dates, one sheet per file.CSV SplitterSplit a large CSV into smaller files by row count, file count or column value, header kept.CSV MergerCombine many CSV files into one, matching columns by name, with dedupe and a source column.VCF to CSV ConverterConvert vCard (.vcf) contacts to CSV for Google or Outlook, or turn a CSV back into a VCF.Calendar Event (.ics) GeneratorCreate an .ics calendar invite with time zone, reminders and repeats + Google/Outlook links.CSV Column ExtractorPick, reorder and rename CSV columns, filter rows by value, and export a new CSV or JSON.CSV Diff CheckerCompare two CSV files by key column and see added, removed and changed rows cell by cell.CSV Duplicate Row RemoverRemove duplicate rows from a CSV by all or selected columns and download the cleaned file.CSV to HTML TableTurn CSV into clean HTML table code with a live preview, styling options and one-click copy.CSV to Markdown TableConvert CSV to a neatly aligned GitHub Markdown table with column alignment and live preview.CSV TransposeSwap rows and columns of CSV, TSV or pasted spreadsheet data, with delimiter auto-detect.Date Format ConverterConvert any date to ISO 8601, RFC 2822, Unix time and custom strftime, moment or Java patterns.ENV to JSON ConverterConvert .env files to JSON or YAML and JSON back to .env, with quotes and multiline values.
See all 129 Data & File Format Converters →