Text tools

Remove Line Numbers

Remove Line Numbers

Strip line numbers from code or text copied from an editor, a PDF or a website.

About this tool

About Remove Line Numbers

Code copied from a tutorial, a PDF, a forum or a terminal often brings its line numbers along, and they have to go before the code will run. Paste it here and the numbers at the start of each line are removed, whatever the format: 12. and 12) as in numbered lists, [12] and (12), 12: as in grep output, 12 | as in some code viewers, and a number followed by a tab, as many editors copy. After prefixes like 12. or 12 | only one space or tab is removed, so the indentation that follows is preserved and Python and YAML still work. Numbers followed only by spaces are trickier, because a line can legitimately start with a number ("2024 was a good year"), so they are removed only when at least four out of five lines start that way, which is what numbered code looks like. Lines without a number are left untouched, and the notice tells you how many lines were changed. Need the opposite? Switch Action to Add numbers. Nothing leaves your browser.

Built and maintained by Abhi JainUpdated

How to Remove Line Numbers

  1. 1

    Paste the numbered text

    Paste the code or text into the Text box. Click Sample to see an example.

  2. 2

    Check the result

    Remove numbers is selected. The notice shows how many lines had numbers removed.

  3. 3

    Copy

    Copy or Download the text without numbers.

Remove Line Numbers: questions and answers

Will indentation be kept?

For prefixes such as 12., 12), [12], 12:, 12 | or 12 and a tab, yes: only the number, its separator and one space or tab are removed, so the indentation that follows stays. When numbers are followed only by spaces, all of those spaces are removed, so check the indentation afterwards.

Why weren't my numbers removed?

Numbers followed only by spaces are removed when at least 80% of non-empty lines start that way. If fewer do, use Find and Replace with the regex ^\s*\d+\s+ and an empty replacement.

Can it remove numbers from a numbered list?

Yes: 1. and 1) prefixes are removed, which turns a numbered list into plain lines. To renumber instead, add numbers again with a new start.

How do I stop copying line numbers in the first place?

Many sites have a copy button that leaves numbers out; in PDFs and some viewers you can hold Alt (Option on Mac) while dragging to select a block that excludes the number column.

More Add Line Numbers presets