Line numbers

Add line numbers to text with your choice of start, padding and separator, or strip them off again.

Input

The text to number, or numbered text to clean.
Add numbers or remove existing ones.
Number given to the first line.
Make all numbers the same width with leading spaces or zeros.
Text placed between the number and the line. Used when adding.
Leave blank lines without a number.

Result

Fill in the input and press Run.

Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.

Use it from code or an agent

curl -s https://setget.net/v1/tools/line-numbers \
  -H 'Content-Type: application/json' \
  -d '{"input":{"text":"alpha\nbeta\ngamma"}}'
import json, urllib.request

body = {'input': {'text': 'alpha\nbeta\ngamma'}}
request = urllib.request.Request("https://setget.net/v1/tools/line-numbers", json.dumps(body).encode(),
                                 {"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/line-numbers", {
  method: "POST",
  headers: {"Content-Type": "application/json"},
  body: JSON.stringify({"input":{"text":"alpha\nbeta\ngamma"}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
  "slug": "line-numbers",
  "input": {
    "text": "alpha\nbeta\ngamma"
  }
}
{
  "input": {
    "text": "alpha\nbeta\ngamma"
  }
}

Endpoint: POST /v1/tools/line-numbers. Over MCP: run_tool with slug: "line-numbers". Machine-readable: input schema, Markdown. Connect an agent.

Inputs

NameTypeRequiredWhat it does
text string yes The text to number, or numbered text to clean.
action string no Add numbers or remove existing ones. One of: add, remove. Default: "add".
start integer no Number given to the first line. Default: 1. From 0 to 1000000000.
padding string no Make all numbers the same width with leading spaces or zeros. One of: none, space, zero. Default: "none".
separator string no Text placed between the number and the line. Used when adding. Default: ": ".
skip_blank boolean no Leave blank lines without a number. Default: false.

Examples

Input
{
  "text": "alpha\nbeta\ngamma"
}
Result
{
  "text": "1: alpha\n2: beta\n3: gamma",
  "lines": 3
}

Zero-padded

Input
{
  "text": "a\nb",
  "start": 9,
  "padding": "zero",
  "separator": " | "
}
Result
{
  "text": "09 | a\n10 | b",
  "lines": 2
}

Removing numbers

Input
{
  "text": "1. alpha\n2. beta",
  "action": "remove"
}
Result
{
  "text": "alpha\nbeta",
  "lines": 2
}

Questions

Which number formats does "remove" understand?
A number at the start of the line, with optional spaces before it, followed by a space, a tab or one of . : ) ] | > -
Will "remove" delete numbers that belong to the text?
Yes, if a line starts with one. "2024 was a good year" loses its "2024". Check the result when lines can start with real numbers.