Insert text at line end
Insert a string at the end of every line or at a position counted backwards from the end (0 appends at the very end). A regular expression can restrict the edit to matching lines, several “position|text” rules can be applied in order, and positions count characters (code points).
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
The insert text and rule texts support the \n, \t and \\ escapes.
Positions count back from the end of the line: 0 appends at the very end, 1 inserts before the last character, and a position longer than the line inserts at the start.
Result
Output always uses LF line endings; a \n inside the inserted text really breaks the line.
Enter text and something to insert to see the result
What this tool does
- Give every line the same tail: add a semicolon, a full stop or a “[done]” marker, or close a bracket that is missing at the end of each line.
- Insert text without disturbing a fixed trailing character: the position counts back from the end of the line, so position 1 inserts before the last character.
- Stack several rules for a compound edit: for example append a marker first, then insert a symbol before the second-to-last character. Rules are applied in the order you write them.
Example
Input
hello world
Output
hell-o worl-d
Insert text “-” with position 1: positions count back from the end, so 1 inserts before the last character.
Frequently asked questions
How exactly is the position counted, and how does it differ from the other insert tool?
This tool counts **from the end of the line towards the start**: 0 appends at the very end (the common case), 1 inserts before the last character, 2 before the second-to-last, and a position longer than the line inserts at the start. The other insert tool counts from the start of the line; the two only agree at position 0 (end) and at the line length (start). Pick whichever direction is easier for the edit you have in mind. Positions count characters (Unicode code points), so an emoji counts as one.
How are several rules combined?
The rules box takes one rule per line as “position|text”: 0|! appends an exclamation mark, 1|~ inserts before the last character. The insert field is applied first, then the rules in the order you wrote them, and later rules see the text already changed by earlier ones — so 0|! plus 1|~ turns hello into hello~!. A line without “position|” means the end of the line, and rules with empty text are ignored.
Can I restrict the edit to some lines?
Yes. “Only lines matching” takes a JavaScript regex source (case sensitive), for example ^# for lines starting with #, and “invert” flips it to lines that do not match; “skip blank lines” leaves lines that are empty after trimming untouched. An invalid regex fails loudly instead of silently editing every line.
Can the inserted text contain a line break or a tab?
Yes. Both the insert field and rule texts support the \n, \t and \\ escapes: \n really breaks the line (which adds output lines) and \\ produces a literal backslash. CRLF and lone CR are treated as line breaks and the output uses LF.
Does it modify my files?
No. Everything runs locally in your browser on the text you paste; no file is read or written, and you can simply copy the result.
Keywords:insert at end of lineappend to every linetxt-insert-back