Skip to content
PithLab

↑↓ to move · Enter to open · Esc to close

Add Prefix and Suffix to Lines 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.

POST /api/v1/tools/add-prefix-suffix-to-linesMCP add_prefix_suffix_to_linesText & Writing

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.

Input

Send these as a JSON object. Unknown fields are rejected.

input
The text, one item per line. (string, required)
mode
add puts the prefix and suffix on each line; strip removes them where present. (string, one of add, strip, default "add")
prefix
Text put before each line. (string, up to 1000 characters, default "")
suffix
Text put after each line. (string, up to 1000 characters, default "")
quote
Wrap each line in quotes (inside the prefix and suffix). (string, one of none, single, double, backtick, default "none")
escapeQuotes
Escape quotes inside a line: doubled for single quotes (SQL style), backslash otherwise. (boolean, default true)
numbering
Put a line number in front of each line. (boolean, default false)
start
First line number when numbering. (integer, -1000000 to 1000000, default 1)
step
Increment between line numbers. (integer, -1000 to 1000, default 1)
padding
Minimum digits for the number, zero-padded. 0 means no padding. (integer, 0 to 20, default 0)
numberSeparator
Text between the number and the line, e.g. ". " or ") ". (string, up to 100 characters, default ". ")
skipEmpty
Drop blank lines. (boolean, default false)
trimLines
Trim spaces at both ends of each line first. (boolean, default false)
joinWith
Text placed between output lines. The escapes \n, \r, \t and \\ are understood. (string, up to 100 characters, default "\\n")
wrapStart
Text before the whole result, e.g. "(". (string, up to 1000 characters, default "")
wrapEnd
Text after the whole result, e.g. ")". (string, up to 1000 characters, default "")
curl https://pithlab.com/api/v1/tools/add-prefix-suffix-to-lines \n  -H "Authorization: Bearer $PITHLAB_KEY" \n  -H "Content-Type: application/json" \n  -d '{"input":"apple\nbanana\ncherry","quote":"single","joinWith":", ","wrapStart":"(","wrapEnd":")","skipEmpty":true,"trimLines":true}'
Example response
{
  "ok": true,
  "result": {
    "output": "(undefined'apple'undefined, undefined'banana'undefined, undefined'cherry'undefined)",
    "lines": 3
  }
}