Remove Duplicate Lines
Remove duplicate lines from text with options for case sensitivity, whitespace trimming, sorting, and keeping first or last occurrence. Includes statistics and duplicate analysis
Line Prefix & Suffix is a free tool to add custom prefix and suffix text to each line with 12 quick presets including quotes, brackets, HTML tags, live preview, and custom separator support.
The task comes up more often than it should, and it always arrives at an inconvenient moment. You have a list of items, one per line. You need each one wrapped in quotes for a SQL query. Or each one needs a comma at the end for a JavaScript array. Or each one needs to become an HTML list item. Or someone has given you a flat list that needs to be transformed into something a script can consume. The options are: do it manually one line at a time, write a regular expression that you will have to look up or reconstruct, open a code editor and use multi-cursor editing, or use a tool that does exactly this one thing quickly.
This tool does exactly this one thing quickly.
The operation is simple enough to state in one sentence: take each line of input, add the prefix text before it and the suffix text after it, and output the result. The value is in having a tool that handles it instantly with live preview and presets for the formats that come up most often.
A list like this:
apple
banana
cherry
With a prefix of "" and a suffix of "", becomes:
""apple"",
""banana"",
""cherry"",
Which is a directly pasteable JavaScript or Python array initialization. With a prefix of <li> and a suffix of </li> it becomes an HTML list. With a prefix of ' and a suffix of ' it becomes single-quoted strings for a SQL IN clause. With a prefix of nothing and a suffix of , it becomes a comma-separated list. The transformation is the same each time. The target format changes.
The presets cover the formats that appear most often without requiring you to type the same characters repeatedly across sessions. Having named presets for common patterns also reduces the chance of inconsistency, like forgetting the closing quote on half the lines when typing manually.
The preset categories cover:
Quoting. Double quotes, single quotes, and backticks are separate presets because they serve different purposes. Double quotes are standard in JSON, JavaScript strings, and CSV. Single quotes appear in SQL, PHP strings, and Python. Backticks are template literals in JavaScript and identifier quoting in MySQL.
Brackets and braces. Wrapping lines in parentheses, square brackets, or curly braces. Parentheses appear in SQL function calls and tuple notation. Square brackets appear in array literals and certain configuration formats. Curly braces appear in template systems, SCSS, and various configuration formats.
HTML tags. List items (<li>...</li>), paragraph tags, <div> wrappers, and similar HTML element wrappers are presets because transforming a plain list into HTML structure is one of the most common use cases for this kind of tool.
Code-oriented formats. Trailing commas for array items, semicolons for statement termination, and other punctuation patterns that differ by language.
Selecting a preset instantly populates the prefix and suffix fields and updates the live preview. If the preset is close but not exactly right, the fields are editable after the preset is applied.
Empty lines in the input are preserved in the output with the prefix and suffix applied, or skipped depending on your preference. The tool handles both cases cleanly.
Building SQL IN clauses. The SQL IN operator expects a comma-separated list of quoted values: WHERE name IN ('Alice', 'Bob', 'Carol'). Starting from a plain list of names, applying single quotes as both prefix and suffix, then adding commas as suffix, produces the correctly formatted list. One copy-paste and it is in the query.
Generating array literals. JavaScript, Python, Ruby, and most other languages use quoted, comma-separated values inside brackets for array initialization. The double-quote with trailing comma preset handles most cases. For languages or contexts that use different quoting conventions, the fields are customizable.
Creating HTML lists. A flat list of items becomes a proper HTML unordered list when each line is wrapped with <li> and </li>. Combined with a manually typed <ul> and </ul> wrapping the output, the transformation from plain text to valid HTML takes seconds.
Formatting configuration values. INI files, environment files, YAML configurations, and various custom configuration formats often require values in specific formats. Adding a consistent prefix like a variable name prefix or a namespace qualifier to a list of keys, or adding quotes around values that need them, is a common configuration preparation task.
Preparing import data. Batch import scripts and database seed files often expect data in specific string formats. If you have a list of values that need wrapping in a particular way before they can be consumed by an import process, this is the tool that handles it without writing a preprocessing script.
Code generation. Turning a list of identifiers, field names, or route paths into code fragments follows the same pattern. A list of field names with this. as prefix and = null; as suffix produces object property initialization statements. A list of route paths with specific method wrappers becomes a set of API endpoint declarations. The pattern is always the same even when the specific strings change.
By default the output preserves the line-by-line structure of the input. The custom separator option lets you change what appears between lines in the output. Setting the separator to , collapses the entire list onto a single line with comma-space between each item. Setting it to | produces a pipe-delimited format. Setting it to an empty string joins all lines together without any separator.
This matters when the target format requires a single line rather than a multi-line list. A JavaScript array initialization is typically on a single line for short lists. A SQL IN clause's value list is usually inline within the query. The separator option handles this without requiring an additional step to join the lines after adding the prefix and suffix.
Line prefix and suffix addition is often one step in a multi-step text transformation workflow. The input frequently needs cleaning or preparation before the prefix and suffix are applied, and the output sometimes needs further processing afterward.
If the input text needs sorting, deduplication, or other list manipulation before the transformation, the Word Counter provides basic text analysis, and the URLs Extractor Tool handles the common case where the input lines are URLs extracted from a larger document. For output that will be embedded in HTML, the HTML Encode tool handles special character escaping for values that contain characters that need entity encoding before going into HTML attributes or content.
Yes. The tool adds the specified prefix and suffix to every line regardless of existing content. It does not check for or deduplicate existing prefix or suffix characters. If you need to add quotes to lines that may already be partially quoted, review the output and adjust manually as needed.
Yes. The prefix and suffix fields accept any text of any length. You can add an entire HTML tag, a multi-word string, or a code fragment as the prefix or suffix. There is no character limit.
Blank lines are processed with the prefix and suffix applied by default, which means a blank line becomes whatever the prefix and suffix contain with nothing in between. If you want blank lines skipped entirely in the output, that option is configurable in the tool settings.
Yes. The tool processes everything client-side in the browser and handles inputs of practical sizes efficiently. For very large files with thousands of lines, the processing is fast enough that the live preview remains responsive.
Text editors with multi-cursor support or find-and-replace regex can perform the same transformation. The advantage of this tool is speed and accessibility: no need to know regex syntax, no need to be in a specific editor, no need to construct the right expression for wrapping content. The presets also provide one-click access to the formats that come up most often without typing anything.