Line Number Tool
Add or remove line numbers from text
Line Number Tool — what it does
Add line numbers to text with a starting number and separator you choose, or strip existing numbers back off. The round trip is the point: number a list to discuss it with someone, then remove the numbering to get clean data back afterwards.
Worked example
A five-line event checklist (with one empty line) numbered from 1 with the default ". " separator.
Input text
Confirm venue booking Send agenda to attendees Print 12 name badges Order catering for 30
Output — numbered
1. Confirm venue booking 2. Send agenda to attendees 3. 4. Print 12 name badges 5. Order catering for 30
The empty third line gets its own number and separator ("3. "); the 12 and 30 inside the text are untouched.
When this tool helps
- Numbering a code snippet or config file so a reviewer can refer to specific lines.
- Preparing a numbered list of items for a discussion or a checklist.
- Cleaning numbers off text copied from a code viewer that included the gutter.
How to use it
- Paste the text.
- Set the starting number and the separator.
- Add numbers, or remove existing ones.
- Copy the result.
Accuracy, limits, and good practice
- Removing numbers is the more common need in practice — copied code from documentation sites usually drags the line gutter along with it.
- A separator like a colon and space, or a pipe, reads better than a bare space when lines start with digits themselves.
- Numbering from something other than one is useful when the snippet is an excerpt from a longer file and should match its real line numbers.
- Choose a separator the text does not already start with, or removal later cannot tell your numbering from the content.
Frequently asked questions
Are blank lines numbered?
They are treated as lines, which keeps the numbering aligned with the original file's structure.
Will removal damage legitimate leading numbers?
Removal targets the numbering pattern at the start of lines, so text that genuinely begins with a number and different punctuation is usually safe — check the output.
Can I add prefixes instead?
The line prefix and suffix tool adds arbitrary text, with a placeholder for the line number if you want both.
Does numbering survive a copy into a code editor?
The numbers become part of the text, so paste numbered code only where you want it read, never where it will be run.
Can I start numbering at 0, or use a negative start?
Not at 0: a starting number of 0 (or an empty box) falls back to 1. Negative numbers work (-2, -1, 0, 1 …), and so do large ones such as 1040 when the snippet is an excerpt from a longer file.
Which numbering formats does Remove recognise?
A leading number followed by one of . ) - : | and optional spaces: "1. ", "2) ", "4: " and "5 - " are all stripped, together with any indentation before the number. A number followed only by a space ("3 Print badges") is left alone, so a bare space cannot be used as a separator you plan to remove later. Remove ignores the start number and separator boxes.
Related tools on this site
- Basic JSON Schema Validator — Validate JSON against common schema rules directly in the browser
- Number Extractor — Extract integers, decimals, and negative values from text
- Word Counter — Count words and characters instantly
Further reading: Cleaning Up Text You Pasted From Somewhere Else
Everything above runs inside this page. Line Number Tool needs no account, no upload, and no server round trip — close the tab and nothing is left behind.
行號工具能做什麼
為文字加上行號,起始號碼與分隔符可自訂,也能把既有行號拿掉。來回兩個方向才是重點:先加號碼以便和別人討論,討論完再移除,取回乾淨的資料。
實際範例
五行活動檢核清單(含一個空行),從 1 開始編號,分隔符維持預設的「. 」。
原文
Confirm venue booking Send agenda to attendees Print 12 name badges Order catering for 30
加上行號後
1. Confirm venue booking 2. Send agenda to attendees 3. 4. Print 12 name badges 5. Order catering for 30
空的第三行同樣得到自己的編號與分隔符(「3. 」);文字裡的 12 與 30 不受影響。
什麼時候用得上
- 為程式片段或設定檔加行號,讓審閱者能指名某一行。
- 為討論或檢查清單準備編號項目。
- 清掉從程式檢視器複製時一併帶進來的行號。
使用步驟
- 貼上文字。
- 設定起始號碼與分隔符。
- 選擇加入行號或移除既有行號。
- 複製結果。
精確度、限制與實務建議
- 實務上「移除」的需求更常見——從文件網站複製的程式碼通常會連行號欄一起帶走。
- 當每行本身就以數字開頭時,用冒號加空格或直線當分隔符,比單一空格更好讀。
- 片段若是長檔案的節錄、需要對上真實行號時,從非 1 的號碼起算就很有用。
- 分隔符請選文字本身不會用到的字元,否則之後移除時分不清哪些是編號、哪些是內容。
常見問題
空行也會編號嗎?
空行同樣視為一行,這樣編號才能與原始檔案的結構對齊。
移除會誤傷本來就在行首的數字嗎?
移除針對的是行首的編號樣式,因此真正以數字加其他標點開頭的文字通常安全——仍請檢查輸出。
可以改成加前綴嗎?
每行前後綴工具可加任意文字,若同時需要行號,也提供對應的佔位符。
貼進程式編輯器後編號還在嗎?
編號已成為文字的一部分,所以帶編號的程式碼只適合貼給人看,絕不能貼去執行。
可以從 0 開始編號,或填負數嗎?
0 不行:起始號填 0(或留空)會退回 1。負數可以(-2、-1、0、1…),1040 這類大數字也可以,適合摘錄自較長檔案的片段。
去掉行號的功能認得哪些格式?
行首的數字後面接 . ) - : | 其中之一,再接可有可無的空格:「1. 」「2) 」「4: 」「5 - 」都會被去掉,數字前的縮排也一併去掉。數字後面只有一個空格的(「3 Print badges」)不會動,所以以純空格當分隔符的編號日後無法去掉;按下去掉行號時,起始號與分隔符兩個欄位都不看。
本站相關工具
- 基礎 JSON Schema 驗證器 — 在瀏覽器中依常用 Schema 規則驗證 JSON
- 數字提取器 — 從文字中提取整數、小數與負數
- 字數統計 — 快速統計字數與字元數
延伸閱讀: 清理從別處貼上的文字
以上步驟全部在這個頁面內完成,行號工具 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。