Add Prefix, Suffix or Line Numbers to Every Line
Prefix, suffix, number, quote and join lines of text.
Use via API
Add (or strip) a prefix and suffix on every line, with optional quoting, numbering and a custom joiner, e.g. to build an SQL IN list or a JS array. Send JSON, get JSON back.
POST https://pithlab.com/api/v1/tools/add-prefix-suffix-to-lines
curl https://pithlab.com/api/v1/tools/add-prefix-suffix-to-lines \
-H "Authorization: Bearer $PITHLAB_KEY" \
-H "Content-Type: application/json" \
-d '{"input":"apple\nbanana\ncherry","quote":"single","joinWith":", ","wrapStart":"(","wrapEnd":")","skipEmpty":true,"trimLines":true}'About the Add Prefix and Suffix to Lines
Add text to the start or end of every line, number lines, wrap them in quotes and join them into an SQL IN list or JS array. Strip a prefix or suffix too.
How to use the Add Prefix and Suffix to Lines
- Paste your lines into the input box, one item per line.
- Type a prefix and a suffix, or pick a preset such as SQL IN list or JS array.
- Optionally add line numbers with your own start, step, zero padding and separator.
- Choose quotes and a join separator to turn the lines into one list, and skip empty lines if needed.
- Switch to Strip mode to remove a prefix or suffix instead, then copy or download the result.
Examples
Input
apple banana O'Brien
Output
('apple', 'banana', 'O''Brien')Input
Install Configure Deploy
Output
01) Install 02) Configure 03) Deploy
Input
- one; - two; three
Output
one two three
Frequently asked questions
In what order are the options applied?
Each line is trimmed if you ask, then wrapped in quotes, then the prefix and suffix are added, then the line number goes in front. Finally the lines are joined with your separator and the whole result is wrapped.
How are quotes inside a line handled?
With escaping on, a single quote is doubled (O'Brien becomes 'O''Brien'), which is how SQL expects it. Double quotes and backticks are escaped with a backslash, as in JavaScript. Turn escaping off to keep the text exactly as is.
How do I join lines with a line break or tab?
Type \n for a line break or \t for a tab in the join separator box. Use \\ for a literal backslash. The default separator is \n, which keeps one item per line.
What does Strip mode do?
It removes the prefix from the start of each line and the suffix from the end, but only where the line really starts or ends with that text. Other lines are left unchanged.
Is my text uploaded?
No. Everything runs in your browser and nothing is sent to a server.