ForHosting KIT · Text & AI

Add line numbers to text

Put a number in front of every line of code, logs, lyrics or notes: alpha, beta and gamma become 1. alpha, 2. beta and 3. gamma. Pick your own separator or first number to continue a list. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Text
alpha beta gamma
You get
Input
alpha beta gamma
Separator
.
Start
1
Line count
3

An add-line-numbers tool turns a raw paste of code, logs, lyrics, or notes into a stable numbered listing you can share in tickets, homework, and reviews. Enter any non-empty multi-line or single-line string; the tool normalizes Windows and classic Mac newlines, splits on each line break, and prefixes every segment with a sequential integer plus your chosen separator—by default a period and space so the familiar 1. style appears without extra setup. Optional start lets you continue a list from zero, one, or any integer within the published range. Developers, teachers, support agents, and content pipelines need that same deterministic numbering without opening a full IDE.

How sequential line numbering works

Line numbering is one of the oldest readability aids in programming and technical writing: each visual line gets an integer label so people can point at “line 17” without quoting half the document. This capability implements that everyday rule on plain text rather than on PDF pages or word-processor paragraphs. First the input is checked: missing text, a non-string value, or a string that is empty after trimming whitespace is rejected so blank pastes never look like success.

Newlines are normalized so Windows CRLF, old Mac CR, and Unix LF all become a single LF form before splitting. The splitter then breaks the string on every LF; each resulting segment—including empty segments between consecutive newlines—is one line and receives its own number. The first number is the integer start value (default one), and each following line increments by one.

Between the number and the original line content the tool inserts the separator string, which defaults to a period followed by a space so the output reads like a classic numbered list. You may pass a different separator such as a colon and space, a closing parenthesis, a pipe, or a tab-like marker, as long as the separator stays within the published character limit. When you need paragraph totals instead of per-line labels, use a blank-line paragraph counter; when you need PDF page stamps, use a PDF page-numbering capability.

This landing is only about prefixing sequential numbers onto plain-text lines.

Practical tips, limits, and when to use this tool

Use this capability when the search intent is add line numbers, number lines online, or sequential line numbering for plain text. Paste a code snippet, log extract, poem, or checklist, convert once, and drop the numbered block into a ticket, email, or student feedback form. Keep intentional trailing newlines in mind: a final LF creates an empty last segment that still receives a number, which matches how many editors treat end-of-file newlines.

Extremely long single lines still count as one line each; the tool does not wrap by character width. HTML and Markdown source are numbered as raw strings; strip markup first if you only want visible prose lines. This landing is not a PDF page-number stamp, not a paragraph counter, not a word or character counter, and not a diff tool that invents hunks.

Prefer PDF page numbering when the document is a multi-page binary PDF; prefer a paragraph counter when humans separated ideas with blank lines and you only need the total; prefer this capability when reviewers must cite exact line indices in plain text. When teaching code review, number the same snippet twice with different separators so learners see how labels stay stable while presentation changes.

Code review and bug reports

Paste a stack trace or snippet, add stable line numbers, and cite “line 12” in tickets without sharing an entire repository.

Homework and worksheet prep

Teachers number poem lines or exercise lists so students can answer by line number on quizzes and worksheets.

Log excerpts for support handoffs

Support agents number multi-line log pastes before escalating so engineers can point at the exact failing line.

How are lines defined?

After normalizing CRLF and CR to LF, the text is split on every LF. Each segment—including empty ones between consecutive newlines—receives a sequential number.

Can I change the separator or starting number?

Yes. Pass separator (default ". ") and start (default 1). Start must be an integer from 0 to 1,000,000; separator is limited to 32 characters.

Does this number PDF pages?

No. It only numbers plain-text lines. Use a PDF page-numbering tool when you need stamps on PDF pages.

Is the line number tool free?

The browser tool is free and runs locally.

Do empty lines get a number too?

Yes. Every empty line between two line breaks is numbered, so the labels match what you see in an editor. A line break at the very end also adds a numbered empty last line.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/str/number-lines

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/str/number-lines \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"alpha\nbeta\ngamma"}'
{
  "text": "alpha\nbeta\ngamma"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "str.number_lines",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_chars100000
max_separator_chars32
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Empty or whitespace-only input is rejected with a clear invalid_input error so automation never treats a blank form as a successful zero-line file.

How to call the API and what the response contains

Prefer sending the raw document body with its real line breaks rather than pre-joining everything into one line when you want true multi-line labels. Send a JSON body with a required string field text (aliases input, value, string, s, content, and body). Optionally include separator (aliases sep and delimiter) as a string of at most thirty-two characters, and start (aliases from, offset, and begin) as an integer between zero and one million inclusive. The text value must be non-empty after whitespace is trimmed and must not exceed one hundred thousand characters so a single request cannot exhaust Worker or browser memory on huge paste dumps. On success the response echoes input as the original string you sent, text as the trimmed working string, separator and start as the effective numbering options, line_count as the number of numbered segments, lines as an ordered array of fully prefixed line strings, numbered as those lines joined with LF, and message as a short English summary that reports how many lines were numbered and with which start and separator. Failed validation—missing text, a non-string value, an oversize payload, empty content after trim, a non-string or oversize separator, or a non-integer or out-of-range start—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item and zero marginal unit price. When integrating, assert on numbered or lines for the full listing, on line_count for the total, and treat invalid_input as a client bug for blank form submissions rather than a billing event.

Practical tips, limits, and when to use this tool

Round-trip checks for tests are easy: feed three short lines separated by LF and expect line_count three with prefixes starting at one and the default separator; change start to ten and expect ten, eleven, twelve; deliberately send empty string or spaces to confirm invalid_input and the message that asks for a non-empty string. Failed tasks that return invalid_input do not consume prepaid balance, which keeps form validation and CI negative tests cheap.

What happens on empty input?

Missing text, non-string values, or strings that are empty after trimming return invalid_input and are never charged.

Read the full KIT documentation →