Categories

Add a Prefix to Text Lines

Quickly prepend a prefix to one or more text lines

Key Facts

Category
Text Processing
Input Types
textarea, text, select, checkbox
Output Type
text
Sample Coverage
4
API Ready
Yes

Overview

This utility allows you to instantly prepend custom text or symbols to the beginning of every line in your document, streamlining formatting and data organization tasks.

When to Use

  • Formatting lists for Markdown or documentation by adding bullet points or blockquote markers.
  • Preparing code snippets or logs by adding comment characters or timestamps to every line.
  • Standardizing data exports by adding specific identifiers or labels to the start of each entry.

How It Works

  • Paste your text into the input area.
  • Define the prefix string you wish to add.
  • Select which lines to target, such as all lines, only non-empty lines, or specific patterns like odd or even rows.
  • Apply optional settings like preserving existing indentation before generating your processed text.

Use Cases

Converting plain text lists into Markdown-formatted bulleted or numbered lists.
Adding comment syntax (like // or #) to a block of code or configuration settings.
Prepending timestamps or category tags to log file entries for better readability.

Examples

1. Creating Markdown Blockquotes

Technical Writer
Background
A writer needs to convert a series of paragraphs into a blockquote format for documentation.
Problem
Manually typing '>' at the start of every paragraph is tedious and prone to errors.
How to Use
Paste the paragraphs into the input, set the prefix to '> ', and select 'All Lines'.
Example Config
prefix: '> ', targetLines: 'all'
Outcome
Every line in the document is automatically prefixed with a blockquote marker, ready for Markdown rendering.

2. Commenting Out Code Blocks

Developer
Background
A developer needs to temporarily disable a block of configuration settings in a text file.
Problem
Adding comment characters to each line individually is inefficient.
How to Use
Paste the configuration lines, set the prefix to '# ', and choose 'Non-empty Lines Only' to avoid commenting out blank spacing.
Example Config
prefix: '# ', targetLines: 'nonempty'
Outcome
All active configuration lines are instantly commented out while maintaining the file's original structure.

Try with Samples

text

Related Hubs

FAQ

Can I add a prefix only to non-empty lines?

Yes, select the 'Non-empty Lines Only' option in the Target Lines dropdown to skip blank lines.

Does this tool support preserving indentation?

Yes, enable the 'Preserve Indentation' checkbox to insert your prefix after the existing leading whitespace.

Can I target specific lines like odd or even rows?

Yes, the Target Lines setting allows you to choose between all lines, empty lines, non-empty lines, or alternating odd/even rows.

Is there a limit to the length of the prefix?

There is no strict character limit for the prefix; you can use any text string that fits your formatting needs.

Will this tool modify my original text?

The tool processes your input and generates a new version; your original text remains unchanged in the input field until you clear it.

API Documentation

Request Endpoint

POST /en/api/tools/text-add-prefix-lines

Request Parameters

Parameter Name Type Required Description
textInput textarea Yes -
prefix text Yes -
targetLines select Yes -
ignoreEmpty checkbox No -
preserveIndent checkbox No -

Response Format

{
  "result": "Processed text content",
  "error": "Error message (optional)",
  "message": "Notification message (optional)",
  "metadata": {
    "key": "value"
  }
}
Text: Text

AI MCP Documentation

Add this tool to your MCP server configuration:

{
  "mcpServers": {
    "elysiatools-text-add-prefix-lines": {
      "name": "text-add-prefix-lines",
      "description": "Quickly prepend a prefix to one or more text lines",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=text-add-prefix-lines",
      "command": "",
      "args": [],
      "env": {},
      "isActive": true,
      "type": "sse"
    }
  }
}

You can chain multiple tools, e.g.: `https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`, max 20 tools.

If you encounter any issues, please contact us at [email protected]