Overview
Introduction
Adding a fixed prefix to text, a namespace, a protocol, a tag, is a one-line operation in code but still convenient to have as a standalone tool for quick edits.
It runs entirely client-side, so nothing you paste is ever uploaded to a server.
What Is String Prefix Adder?
A prefixing tool that concatenates your chosen prefix in front of the input text.
It runs entirely client-side as part of this site's String Tools collection, so nothing you paste is ever uploaded to a server.
How String Prefix Adder Works
The tool simply returns `prefix + input`.
The transformation happens synchronously in JavaScript the moment you type, with no network round trip involved.
When To Use String Prefix Adder
Use it to quickly prepend a namespace to an identifier, a protocol to a URL, or a tag to a filename.
It's a fast way to get the answer without opening a code editor, a REPL, or writing a one-off script just to check.
Often used alongside String Suffix Adder and Find & Replace Tool.
Features
Advantages
- Simple and predictable, a direct string concatenation.
- Concatenates without trimming either side, so leading whitespace in your text is preserved precisely where it was.
- Treats the whole input as one value, which is what makes it safe for multi-line text that needs to keep its structure.
Limitations
- Adds the prefix once to the whole input, not per line.
- Adds the prefix a single time, so prefixing a list of values means running it once per value.
Examples
Best Practices & Notes
Best Practices
- For per-line prefixing across multiple lines, process each line individually rather than relying on a single whole-input prefix.
- Include the separator in the prefix itself, such as a trailing slash for a path or a colon for a namespace.
- Check for a doubled separator when the text already begins with one, since nothing is deduplicated for you.
Developer Notes
The implementation is a single string concatenation (`prefix + input`), with no per-line splitting.
String Prefix Adder Use Cases
- Prepending a namespace to a variable or identifier
- Adding a protocol prefix to a bare domain
- Tagging a filename with a fixed prefix
Common Mistakes
- Expecting the prefix to be added to every line of multi-line input.
- Expecting per-line behaviour and pasting in a whole list, which then receives the prefix only on its first line.
Tips
- Use Add a Suffix to a String for the equivalent operation at the end of the text.
- Pair it with the String Suffix Adder to wrap a value on both sides, such as building a complete URL from a path fragment.