ForHosting KIT · Text & AI

Indent lines by spaces

Indent hello and world by 4 spaces and both lines shift right, adding 8 characters in total. Blank lines receive the same spaces, existing indentation is kept, and nothing inside a line changes. 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
hello world
Spaces
4
You get
Input
hello world
Text
hello world
Line count
2
Lines
hello, world

A line-aware indent tool prefixes every line of your paste with a fixed number of ASCII spaces so nested code blocks, block quotes, and hierarchical lists line up without opening an IDE. Enter any non-empty multi-line string—source snippets, chat dumps, Markdown drafts, or log excerpts—plus the integer count of leading spaces you want, and the tool normalizes line endings, splits on newlines, and prepends the same space run to each line while leaving the rest of the line untouched. Writers, developers, documentation authors, and support agents need that same per-line rule when nesting content under another block or when a style guide asks for a four-space shift.

What per-line space indent means and when to use it

You provide the text and a non-negative integer spaces value between zero and two hundred. After Windows CRLF and legacy CR endings are normalized to a single LF form, the string is split on LF, every segment—including blank lines—receives a prefix of exactly that many ASCII space characters, and the segments are joined again with LF.

Existing leading spaces already on a line are kept: the tool always adds the requested amount rather than re-indenting to a target column, so nesting a block that already has two spaces under another level of four spaces yields six spaces on those lines. Interior spaces between words stay put; trailing content is never trimmed or collapsed. Zero spaces is allowed and returns the newline-normalized text with no extra prefix, which is useful for testing the pipeline without shifting content.

Missing spaces, a non-integer, a negative count, or a value above two hundred also fail validation. Prefer this tool when the search intent is indent lines by spaces, add leading spaces to every line, or nest a multi-line block under Markdown or email quotation—not when you only need to pad a single short string to a fixed width.

Practical tips, limits, and related searches

Use this capability when the search intent is indent lines by spaces, add leading spaces multiline, code block indent online, or nest quoted text with a fixed space run. Keep language-aware formatters out of scope: this tool does not know Python or YAML significance of indent depth beyond the literal spaces you request, and it never converts tabs. HTML source and Markdown still indent each raw line of the string you send; strip tags first if you care about rendered text rather than markup.

When teaching students or onboarding reviewers, show the same sample before and after with spaces set to two and four so they see that only the leading edge of each line grows and that word-internal spacing is left alone.

Nest code samples under documentation

Docs authors paste a snippet and indent every line by four spaces so Markdown or reStructuredText treats the block as nested code under a list item.

Quote multi-line replies in tickets

Support agents indent customer paste with two spaces (or more) before wrapping it in a quote style so nested conversation threads stay readable.

Does this convert tabs to spaces?

No. It only prepends ASCII space characters. Existing tabs inside or at the start of a line are left unchanged.

What happens on empty input?

Provide a non-empty string that has at least one non-whitespace character.

Are blank lines indented too?

Yes. Every line after the split—including blank ones—receives the same leading space prefix so block structure stays consistent.

How are Windows line endings handled?

CRLF and lone CR are normalized to LF before splitting so the same paste produces the same result on every platform.

Is the line indent tool free?

The browser tool is free and runs locally.

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/indent-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/indent-lines \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"hello\nworld","spaces":4}'
{
  "text": "hello\nworld",
  "spaces": 4
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "str.indent_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.

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 paste as a successful indent.

What per-line space indent means and when to use it

Most editors indent a selection by inserting spaces or tabs at the start of each selected line; this capability does the same job as a focused, API-ready transform. Empty or whitespace-only whole input is a hard error: there is no meaningful indented document to return, and callers should treat that as invalid_input rather than a zero-line success.

How to call the API and what the response contains

The spaces value must be a finite integer from zero through two hundred inclusive. Prefer sending the raw multi-line body rather than pre-joining lines when you want true per-line semantics. Send a JSON body with a required string field text (aliases input, value, string, s, content, and body) and a required integer field spaces (aliases n, indent, count, amount, and pad). The text must be non-empty after overall 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, spaces as the normalized integer count applied, text as the fully indented result joined with LF, line_count as the number of lines after split (including empty ones), lines as an ordered array of the indented line strings, chars_before and chars_after as the lengths of the original and indented strings, chars_added as how many characters the prefixes introduced in total (typically line_count times spaces, adjusted if newline normalization shortened the original), and message as a short English summary that reports the line count, spaces, and characters added. Failed validation—missing text, a non-string value, an oversize payload, empty content after overall trim, or an invalid spaces count—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item. When integrating, assert on text or lines for the indented content, optionally compare chars_added for regression checks, and treat invalid_input as a client bug for blank form submissions rather than a billing event.

Practical tips, limits, and related searches

Round-trip checks for tests are easy: feed two short lines with spaces equal to four and expect each line to start with four spaces; feed a blank line between content and confirm that empty line also carries the same prefix; deliberately send empty string or only spaces to confirm invalid_input and the message that asks for a non-empty string; send a negative spaces value or a float to confirm invalid_input on the count field. If you need to strip leading and trailing whitespace per line instead of adding spaces, use the sibling trim-lines tool; if you need to pad a single string to a total width with a fill character on left or right, use string pad; if you need pretty-printed JSON with structural indent, use a JSON formatter. Failed tasks that return invalid_input do not consume prepaid balance, which keeps form validation and CI negative tests cheap. Stay within the character and spaces caps documented above when batching large dumps through the API.

Unit tests for text preprocessors

Generate known-good indented multi-line fixtures and empty-input or bad-count rejections for editors, ETL stages, and markdown pipelines.

Read the full KIT documentation →