Add Prefix and Suffix
Add a prefix and/or suffix to each line of text.
Back to all tools on ToolForge
Input
Result
About Add Prefix and Suffix
This tool adds a prefix and/or suffix to each line of text instantly. It's useful for formatting lists into SQL statements, markdown bullet points, code arrays, config entries, log tags, and other structured data formats without manual editing.
Common Prefix Examples
| Use Case | Prefix | Example Output |
|---|---|---|
| Markdown bullets | - |
- item1 |
| SQL values | (' |
('value1 |
| Code comments | // |
// line1 |
| Log tags | [INFO] |
[INFO] message |
| JavaScript strings | ' |
'text |
Common Suffix Examples
| Use Case | Suffix | Example Output |
|---|---|---|
| SQL value separator | '), |
value1'), |
| Statement terminator | ; |
line1; |
| Array comma | , |
item1, |
| Closing quote | ' |
text' |
| Log pipe separator | | |
msg | |
Combined Prefix + Suffix Examples
SQL INSERT values:
Prefix: "('", Suffix: "'),"
Input: apple
banana
cherry
Output: ('apple'),
('banana'),
('cherry'),
JavaScript array:
Prefix: " '", Suffix: "',"
Input: red
green
blue
Output: 'red',
'green',
'blue',
Markdown list with bold:
Prefix: "- **", Suffix: "**"
Input: item1
item2
Output: - **item1**
- **item2**
Special Characters and Escape Sequences
The tool supports escape sequences in prefix and suffix fields:
\n- Newline character\t- Tab character\\- Literal backslash
Example: Use prefix "\t- " to add a tab followed by a bullet point.
Common Use Cases
- SQL Formatting: Convert lists to VALUES clauses for INSERT statements
- Code Generation: Create array literals, enum values, or constant lists
- Markdown Editing: Add bullet points, checkboxes, or numbered list markers
- Log Processing: Add timestamps, log levels, or tags to each line
- Config Files: Format YAML lists, JSON arrays, or INI entries
- Data Preparation: Wrap values in quotes, brackets, or other delimiters
Line Ending Behavior
The tool preserves empty lines in the input. Each line (including empty ones) receives the prefix and suffix. Line endings are normalized to LF (\n) in the output.
How to Add Prefix and Suffix to Lines
- Enter text: Paste or type the lines you want to modify.
- Enter prefix: Type what should appear at the start of each line (e.g., "- " for bullets).
- Enter suffix: Type what should appear at the end of each line (e.g., "," for arrays).
- Click Add Prefix/Suffix: Each line is instantly prefixed and/or suffixed.
- Copy result: Use the formatted output in your code, config, or document.
Tips
- Leave prefix or suffix empty to add only one or the other
- Use escape sequences \n and \t for newlines and tabs
- Remove trailing commas from the last line manually if needed
- Combine with other tools for complex text transformations
Frequently Asked Questions
- How does the prefix/suffix addition work?
- The tool splits input by line breaks, prepends the prefix and appends the suffix to each line, then joins them back. Empty lines are preserved. Escape sequences like \n and \t in prefix/suffix are converted to actual newlines and tabs.
- What are common use cases for adding prefixes?
- Common prefix use cases: bullet points (- or *), SQL values (VALUES ('...'),), code comments (// or #), array elements (, for CSV), log tags ([INFO], [ERROR]), and markdown list items (- or 1.).
- What are common use cases for adding suffixes?
- Common suffix use cases: SQL commas for value lists, semicolons for statements (;), JavaScript array commas, trailing commas for config files, pipe symbols for log parsing, and closing quotes or brackets.
- Can I add both prefix and suffix at the same time?
- Yes, enter values in both fields. For example, prefix with "['" and suffix with "']" wraps each line as a quoted string in brackets: ['item1'], ['item2'].
- How do I format a JavaScript array from a list?
- Use prefix: " '" (two spaces and quote) and suffix: "'," (quote and comma). For the last line, manually remove the trailing comma. Wrap with [ and ] brackets for a complete array literal.
- How do I create SQL INSERT values from a list?
- Use prefix: "('" and suffix: "')," to get ('value1'), ('value2'), etc. Remove the trailing comma from the last line, then prepend "INSERT INTO table (column) VALUES" for a complete statement.