Select language

Interface controls and tool names are translated. Detailed instructions, legal text and some form labels remain in English. Your files are not translated.

Easy To Use - 140+ Free Online Tools

Trim Text Lines

Remove leading and trailing whitespace from each line.

Drop your files here

or

Choose files

Max 100 MB per file · TXT, TEXT, LOG

    Text options

    UTF-8 files only. Up to 300,000 characters per file.

    Your file is ready!

    Download
    Free No watermark No sign-up Files never uploaded
    Python or YAML file?Do not trim — their indentation matters.
    List copied from a PDF?Trim it before sorting or removing duplicates.
    Excel import broken?Hidden spaces are often why.

    How to use Trim Text Lines

    1. Select your text files.Add UTF-8 text up to 2 MB copied from PDFs or websites.
    2. Click Trim Text Lines.Spaces and tabs at the start and end of each line are removed.
    3. Download your TXT file.Spaces between words, empty lines and line endings stay.
    4. Check the text.Extra spaces at the start and end of lines are removed.

    About Trim Text Lines

    When is it useful? Trim Text Lines removes spaces and tabs from the start and end of every line — the invisible spaces that break imports into Excel, cause duplicate entries, or make code and lists look untidy.

    Good to know: only spaces at the beginning and end of each line are removed; spaces between words stay. Empty lines are kept as empty lines, and the line ending style (Windows or Unix) and final newline of your file are preserved.

    Example: you copy a list of names from a PDF and paste it into a text file, but many lines start with spaces or tabs. After trimming, every name starts at the left edge, so sorting and removing duplicates work correctly and the list imports neatly into Excel.

    Tips for Better Results

    • Trim lists copied from PDFs and websites before sorting or removing duplicates.
    • Do not trim Python or YAML files — their indentation matters.
    • The file must be UTF-8 and up to 2 MB.

    Frequently Asked Questions

    Are spaces between words removed?
    No. Only spaces at the beginning and end of each line are removed.
    Are empty lines deleted?
    No. Empty lines are kept, and the Windows or Unix line endings are preserved.
    Which files should I not trim?
    Python or YAML files — their indentation matters.
    Works with: Notepad · TextEdit · VS Code · Excel imports · most text editors

    What converts well, and what doesn't

    In your fileAfter trimming
    Spaces and tabs at start and endRemoved
    Spaces between wordsStay
    Empty linesKept as empty lines
    Line ending style (Windows or Unix)Preserved
    Final newlinePreserved
    💡 Tip: Trim lists copied from PDFs and websites before sorting or removing duplicates.

    Common uses

    Excel importsFix broken imports.
    Copied listsClean PDF text.
    DuplicatesStop false duplicates.
    Website textTidy pasted lines.
    Name listsAlign to the left.
    Data clean-upRemove hidden spaces.

    Is my file safe?

    Browser processing: your files are processed on your own device and are never uploaded to our server.

    Advertisement
    Guide

    Trim Text Lines: a complete guide

    The problem with invisible spaces

    Text copied from PDFs, websites, spreadsheets and emails often carries spaces and tabs at the start or end of lines. You cannot see them, but they break Excel imports, make duplicate checks fail, spoil alphabetical sorting and cause login and form errors.

    How it works

    Upload a UTF-8 .txt file of up to 2 MB. Spaces, tabs and other whitespace at the beginning and end of every line are removed. Spaces between words stay, empty lines remain empty lines, and the file's line-ending style (Windows or Unix) and final newline are kept.

    When not to trim

    Some files depend on leading spaces: Python code, YAML configuration files, Markdown with indented code, and text aligned with spaces for display. Trimming such files can break them, so use this tool for lists and plain text rather than code.

    Common problems and how to fix them

    Extra spaces between words remain: this tool only trims line ends — use your editor's Find and Replace for double spaces. A list still has blank lines: empty lines are kept on purpose; delete them in your editor. “Not valid UTF-8”: save the file as UTF-8 first.

    Good habits

    Trim before sorting and removing duplicates, keep the original file, and avoid trimming code files.

    Advertisement