XTools Logo
XTools
Blog
/
Text ConversionText Compare (Diff)Lorem Ipsum GeneratorMorse, Braille & NATO AlphabetClassical CipherASCII Art GeneratorSort & Clean Lines

© 2026 XTools. All rights reserved.

Privacy PolicyContact Us

    Sort & Clean Lines

    Sort, deduplicate, reverse, shuffle, trim, number, and repeat lines of text
    • Files never leave your device
    • Runs in your browser
    • Free, no sign-up, no watermark
    1
    1

    Clean up

    Sort

    Filter & replace

    Format

    Leave empty to use line breaks. Example: , or ; or \t

    Leave empty for one item per line. Example: , or \t

    Related tools

    • Text Conversion
    • Text Compare (Diff)
    • Lorem Ipsum Generator
    • Morse, Braille & NATO Alphabet
    • Classical Cipher
    • ASCII Art Generator

    How to use Sort & Clean Lines

    Clean up lists line by line: trim spaces, remove empty and duplicate lines, sort (including natural, numeric and Chinese pinyin or stroke order), filter, find and replace with regular expressions, and add prefixes or line numbers. A second mode repeats text as many times as you need.

    1. 1

      Choose Clean & sort lines or Repeat text at the top.

    2. 2

      Paste your list into Input, one item per line; if items are separated by commas or tabs, enter the separator in Split input on.

    3. 3

      Turn on the cleanup options you need, such as Remove empty lines and Remove duplicate lines, then choose a Sort order and Alphabet order.

    4. 4

      Optionally use Filter & replace and Format to keep or drop matching lines, replace text, or add text and numbers to every line.

    5. 5

      Copy the Result, download it as .txt, or click Use as input to run another pass.

    Frequently asked questions

    Which copy of a duplicate line is kept?

    The first occurrence. Turn on Ignore case when comparing to treat "Apple" and "apple" as the same line.

    What is the difference between Natural and Numeric sorting?

    Natural keeps numbers inside text in order, so item2 comes before item10. Numeric sorts by the first number found in each line. By length puts the shortest lines first.

    How do I sort Chinese by pinyin or stroke count?

    Set Alphabet order to Chinese (pinyin) or Chinese (stroke count). Sorting uses your browser’s built-in language rules, so results can differ slightly between browsers.

    Can I use regular expressions?

    Yes. Turn on Regular expression for the filter or for find and replace, and use $1 for groups in Replace with. \n and \t work in Find and Replace with, and an invalid pattern shows an error.

    How do I turn a comma-separated list into one item per line, or back?

    Enter , in Split input on and leave Join output with empty to get one item per line. To join a column into one line, leave Split input on empty and enter , in Join output with.

    How many times can text be repeated?

    Up to 100,000 times, as long as the result stays under 20 million characters. Turn on Replace {n} with the copy number to number each copy.