Adding a prefix to each line means inserting the exact same literal text in front of every line of a block of text, turning items such as apple, banana and cherry into - apple, - banana and - cherry when the prefix is a single dash followed by a space. The transformation keeps the original line content exactly as it was, places the prefix at the front of it, and produces one decorated line for every line that came in. A prefix is not a regular expression and the tool does not look for patterns inside lines. Every line receives the same literal string, so characters like brackets, backslashes, asterisks, parentheses, and dollar signs appear in the output exactly as typed. That property is what makes the operation reliable for Markdown bullets, code comments, SQL fragments, logging tags, and shell prompts. The Add Prefix and Suffix to Lines tool from Lizely performs the transformation locally in the browser, with a preview that shows the exact output and a UTF-8 TXT file that can be downloaded at the end. The text is never sent to a server, so the same tool works for source code, internal logs, and any other material that should not leave the local machine.

add prefix to each line example
add prefix to each line example

What a Prefix-to-Each-Line Transformation Produces

A prefix-to-each-line transformation takes a block of text, keeps every line intact, and decorates the start of each one with the same literal string. The output mirrors the input one-for-one: a three-line input produces a three-line output where the only difference is that each line now starts with the prefix.

A plain three-item list looks like this before the transformation:

  • apple
  • banana
  • cherry

With the prefix "- " applied, the same three lines look like this afterwards:

  • - apple
  • - banana
  • - cherry

Nothing inside the original line changes. Leading spaces, tabs, and indentation are preserved, and the line count of the output is the same as the line count of the input. The "literal" part of the operation is what makes the result predictable: the prefix string is not parsed as a regex, not expanded from a template, and not interpreted as Markdown or HTML. Brackets, quotes, dollar signs, backslashes, asterisks, and parentheses are inserted exactly as they appear in the prefix field.

Concrete Tasks Solved by Adding a Prefix to Each Line

Decorating every line with the same opening string is one of the most common text operations in shell, code, and content work. The pattern fits anywhere the same character sequence is needed at the start of every line:

  • Markdown bullets and task lists: turn plain words into - item or * item entries in one pass.
  • Source code comments: prepend //, #, --, or % in front of every line so an active block becomes inert without deleting the underlying text.
  • Log and trace tags: stamp [INFO], [DEBUG], or [ERROR] at the start of every emitted line so a log aggregator can group entries.
  • SQL fragments: build a SELECT column list or an INSERT column list from a one-column-per-line block by prefixing each line with the keyword and a comma.
  • Path and namespace additions: prepend a route prefix like /api/v1/ to every line of an endpoint list to produce full URL routes.
  • Quoting and bracketing: surround each line with a leading quote, bracket, or parenthesis while a suffix handles the closing character.
  • Indentation and outlining: add two or four spaces at the front of every line to nest blocks visually inside a longer document.

Add a Prefix to Each Line in 3 Steps

The quickest way to run a literal prefix transformation is to use a browser tool that performs the operation locally. Add Prefix and Suffix to Lines processes up to one million characters without uploading anything and exports the result as a UTF-8 plain-text file.

  1. Paste or type the lines to decorate. Open the tool and put up to one million characters of text into the input area. Line order and the original line content are preserved, and the tool does not trim the start or end of any line, collapse internal spaces, change letter case, remove tabs, sort entries, or deduplicate values.
  2. Enter a prefix, a suffix, or both. Type the literal opening string in the prefix field. If a closing string is also needed, fill the suffix field as well. Each prefix and suffix is capped at 200 Unicode characters, and at least one of the two must be non-empty because producing an unchanged duplicate would add no value.
  3. Choose the blank-line policy and generate. Toggle whether blank lines should remain unchanged, click generate, inspect the preview, and download the UTF-8 TXT file. Editing the input, the prefix, the suffix, or the blank-line setting clears the previous result and revokes its download URL, which prevents an earlier result from remaining downloadable after the controls describe a different output.

The whole flow runs in the browser. The text never reaches a remote server, so the same procedure is appropriate for source code, internal logs, and any other material that should stay on the local machine.

Worked Examples You Can Copy

The four examples below use the same three-line input and a short prefix. They show the result to expect so the pattern can be tested before being applied to a real block of text. The prefix is shown to the left and the produced decorated line is shown on the right of each arrow.

Example 1: build a Markdown bullet list

Prefix: -

  • apple → - apple
  • banana → - banana
  • cherry → - cherry

This is the canonical "make a bullet list" case. Adding a space after the dash keeps the rendered Markdown readable, since most flavours treat "- apple" and "-apple" as different list markers.

Example 2: comment out a code block

Prefix: #

  • apple → # apple
  • banana → # banana
  • cherry → # cherry

Many shell, Python, Ruby, and YAML dialects treat a leading # as a comment marker. Adding "# " to every line of an active block converts that block into one the interpreter ignores, while the original text remains visible and recoverable.

Example 3: tag log lines with a status

Prefix: [INFO]

  • apple → [INFO] apple
  • banana → [INFO] banana
  • cherry → [INFO] cherry

Square-bracket tags are common in logging libraries and structured log aggregators. Because the prefix is inserted literally, the brackets and the space after them survive into the output untouched, with no regex escaping required.

Example 4: prefix a path or route

Prefix: /api/v1/

  • apple → /api/v1/apple
  • banana → /api/v1/banana
  • cherry → /api/v1/cherry

Each endpoint name becomes a fully-qualified URL route. The forward slash is treated as an ordinary character: no URL encoding, no whitespace stripping, and no path normalization is performed on the original line.

For a longer list of ready-made prefix strings covering SQL, JSON, TOML, Dockerfiles, and CSS, see the Add a Prefix to Each Line: Cheat Sheet of Patterns guide.

Blank Lines and Edge Cases

A direct example usually has no empty lines, but real pasted text almost always does. The table below describes how each blank-line setting behaves across empty lines, whitespace-only lines, and lines that contain real content.

SettingEmpty lineWhitespace-only lineLine with content
Skip blank lines enabledreturned exactly unchangedreturned exactly unchanged (spaces preserved)decorated with prefix and suffix
Skip blank lines disableddecorated with prefix and suffixdecorated with prefix and suffix (spaces preserved)decorated with prefix and suffix

The "skip blank lines" option treats both empty strings and whitespace-only strings as blank. A line that contains any non-whitespace character is always decorated, and internal whitespace on a decorated line is never trimmed or collapsed, so leading tabs and trailing spaces survive into the output.

Line endings are normalized to LF. Windows CRLF, classic Mac CR, and Unix LF boundaries are all recognized on input and converted to LF in the generated file, which means a Windows-style paste and a Unix-style paste produce the same download. A trailing newline in the input creates a final empty logical line; with skip blank lines enabled that line stays empty, and with the option disabled that line receives the prefix and suffix. This is deliberate so the result does not silently lose the boundary represented by the input. A visual wrap in the preview does not add a real newline to the downloaded file.

Limits and Behaviour to Keep in Mind

The tool is intentionally narrow. It only concatenates prefix + original line + suffix for each line selected by the blank-line policy and joins the result with LF. It does not find and replace text inside lines, add sequential numbers, parse CSV fields, edit a Word document, or infer syntax. For numeric prefixes that count up from a chosen starting value, Add Line Numbers to Text is the matching tool, and Find and Replace Text is the matching tool when the goal is to change substrings inside each line.

The downloadable file is a UTF-8 plain-text Blob. It carries no byte-order mark, no rich-text styling, no spreadsheet quoting, no CSV escaping, and no filename-derived prefix. If a downstream format has its own escaping rules, such as a JSON array, a SQL IN clause, or a CSV row, the result has to be quoted or escaped for that format separately. The Blob reference at MDN's Blob documentation explains how a Blob with the text/plain MIME type is constructed in JavaScript and why the resulting file is plain bytes rather than rendered HTML.

The input is bounded to one million characters to keep browser memory use and rendering responsive during large transformations, and each prefix and suffix is capped at 200 Unicode characters. Emoji and non-Latin text are inserted because the operation uses JavaScript strings and the generated Blob is labeled UTF-8 plain text, so characters from any script the system font can render pass through unchanged. Empty input and exceeded limits raise visible errors rather than producing a partial result, which keeps the download in sync with what the preview shows.