Logo

MonoCalc

/

Line Prefix and Suffix Adder

Text
Paste or type text above to get started.
0 lines0 chars0 BNo line breaks

Quick presets

Mode

Wraps each line in a prefix and a suffix at once, which is how HTML tags, brackets and quotes are applied in bulk.

Tokens {n}, {i} and {line} are expanded on every line.Enter a prefix or a suffix to transform the text.
Tokens {n}, {i} and {line} are expanded on every line.

One line will look like this

your line
First value used by the {n} token.
Added to the counter for each transformed line.
Pads {n} to this width, so 1 becomes 001.

Skip empty lines

Trim each line first

Preserve indentation

Skip suffix on the last line

Interpret escape sequences

Remove duplicate lines

Reverse line order

Applied before the prefix and suffix are added.
Writing LF for this text.
Enable the range toggle below to use this.
Lines outside the range are copied through untouched.

Apply to a line range only

Glue used for the optional one-line version of the result.

Nothing to wrap yet

Paste a list above, drop a .txt, .md, .csv or .log file onto the box, or load the sample and try a preset.

About This Tool

Line Prefix and Suffix Adder – Wrap Every Line at Once

Almost every day someone is handed a bare column of values and needs it in a shape another system will accept. A list of country codes has to become a quoted SQL IN list. A list of package names has to become npm install commands. A list of menu items has to become <li> tags. A block of code has to be commented out without losing its indentation. A line prefix and suffix adder turns each of those chores into two text fields and a live preview, instead of a multi-cursor session in an editor or a throwaway regex you will get wrong once.

Prefix, suffix, or both

The core operation is simple: every line becomes prefix + line + suffix. Supply only a prefix of - and a plain list becomes a Markdown bullet list. Supply only a suffix of ; and every line becomes a terminated statement. Supply both — <li> and </li> — and each line is wrapped. Blank lines are skipped by default, so the empty separator between two blocks does not turn into a stray bullet, and the transformation is applied line by line rather than to the text as a whole.

Building valid lists: the last-line problem

The reason hand-built lists break is the trailing separator. Append a comma to every line and the final one carries a comma too, which is a syntax error in SQL, JSON, and most function-argument lists. Turning on skip suffix on the last line emits the final transformed line without it. The dedicated wrap in quotes mode goes further: it keeps the closing quote on that last line and drops only the separator, so US CA MX becomes "US", "CA", "MX" — valid the moment you paste it. Quotes already inside a line can be escaped automatically so an entry such as the "bahamas" does not terminate the string early.

Tokens turn a prefix into a small template
{n} inserts an auto-incrementing counter with your own start value, step, and zero-padding, {i} gives the 0-based index, and {line} repeats the line content. A prefix of {n}. produces a numbered recipe; a template of npm install {line} --save produces a runnable shell block.

Commenting code without destroying alignment

Prepending // at column zero flattens a nested block and makes the result unreadable when you uncomment it later. Preserve indentation inserts the prefix after the existing leading spaces or tabs, so a function body keeps its structure. The inverse remove prefix and remove suffix modes undo the change using a guarded strip: a line is only shortened when it genuinely begins or ends with the string you supplied, so a mixed block of commented and uncommented lines survives intact and nothing is silently truncated.

Preparing the text before it is wrapped

Real input is rarely tidy. Each line can be trimmed before wrapping so invisible trailing spaces do not end up inside your quotes, duplicates can be dropped, and the list can be sorted A→Z or Z→A or reversed first. A line range restricts the whole transformation to lines N through M, which is how you wrap a single section of a long file. Escape sequences such as \t and \n typed into the affix fields are interpreted as real tabs and newlines.

Line endings and what the numbers mean

Windows terminates lines with \r\n while Unix, macOS, and Git use a bare \n. The detected convention is shown as a badge, preserved by default, and can be forced either way on the output — the usual fix for a file that opens as one giant line. Every pass reports how many lines were transformed and how many were skipped and why, alongside the character delta, the true UTF-8 byte size, and the longest and shortest resulting line. The result copies to the clipboard, downloads as .txt or as a CSV pairing each original line with its transformed version, and can be swapped straight back into the input for a second pass. Everything runs locally in your browser, so internal identifiers and unreleased code never leave your machine.

Frequently Asked Questions

Is the Line Prefix and Suffix Adder free?

Yes, Line Prefix and Suffix Adder is totally free :)

Can I use the Line Prefix and Suffix Adder offline?

Yes, you can install the webapp as PWA.

Is it safe to use Line Prefix and Suffix Adder?

Yes, any data related to Line Prefix and Suffix Adder only stored in your browser (if storage required). You can simply clear browser cache to clear all the stored data. We do not store any data on server.

How does the Line Prefix and Suffix Adder work?

Your text is split on every line terminator — CRLF, LF, or a bare CR — and each line is rebuilt as prefix + line + suffix. The selected mode decides which of those two strings is used: add one, add both, wrap the line in quotes, number it with an auto-incrementing counter, substitute it into a template, or strip a prefix or suffix back off. The rebuilt lines are then rejoined with the line ending you asked for.

What do the {n}, {i} and {line} tokens do?

In a prefix, suffix, or template, {n} is replaced by a 1-based counter that honours your start value, step, and zero-padding, {i} is the 0-based index, and {line} is the untouched content of the line. A prefix of "{n}. " produces a numbered list, while a template of "alias {line}='cd {line}'" repeats the same line twice in one output row. Substitution runs in a single pass, so a line that happens to contain the text {n} is never re-expanded.

Why does my comma-separated list end with a stray comma?

Because a suffix is added to every line by default, including the last one. Turn on Skip suffix on the last line and the final transformed line is emitted without it, which is exactly what a SQL IN clause, a JSON array, or a function argument list needs. The Wrap in quotes mode keeps the closing quote on that last line and drops only the separator.

Will adding a comment prefix ruin my code indentation?

Not if you turn on Preserve indentation. With it enabled the prefix is inserted after the leading spaces or tabs rather than at column zero, so a nested block stays aligned when you comment it out. Leaving it off glues the prefix to the very start of the line, which is what you want for Markdown bullets and quoted values.

Can I undo a transformation I already applied?

Yes — the Remove prefix and Remove suffix modes are exact inverses of the add modes. They use a guarded strip, meaning a line is only shortened when it genuinely starts or ends with the string you supplied, so lines that never received the prefix come through untouched and nothing is silently eaten. If no line matches at all, the tool warns you instead of returning an unchanged result without explanation.

Is my text uploaded anywhere?

No. All splitting, wrapping, and rejoining happens in your browser with plain JavaScript, and nothing is sent to a server — which matters because this tool is usually pointed at internal identifiers, customer exports, and unreleased code. Files you drag in are read locally, input is capped at 2 MB, and the share link carries only your settings, never the text itself.