CSV Column Merger

Combine two selected columns into one column using a customizable separator (e.g. merge First Name & Last Name into Full Name).

How to Use the CSV Column Merger

1

Paste CSV Data

Paste your CSV spreadsheet data into the input box or click Load Sample.

2

Configure Merge

Choose the two columns to combine, set your joining separator, and designate a new header title.

3

Merge & Export

Click Merge Columns to combine values across every row, then Copy or Download.

Tool Options

Custom Joining Separators

Join column values using single spaces, hyphens, underscores, comma-spaces, slashes, or custom strings.

In-Place or Append Mode

Replace both original columns with the merged column directly, or keep existing columns and append the result.

RFC 4180 Escaping

Preserves all quotation marks, commas, and line breaks without corrupting delimited data structure.

Your Data Privacy

Web Tool
Privacy-First Architecture
Most of our web tools process your data entirely in-browser. Where server processing is technically required, payloads are evaluated statelessly in-memory and are never stored, saved, or logged.
REST API
Stateless In-Memory Processing
When you use our API endpoints, your requests are processed strictly in-memory without persistent database storage, disk logging, or data retention.
Want to learn more about how we safeguard your information and infrastructure?
Read our full Privacy Policy for detailed security standards, data retention principles, and compliance guarantees.

What does the CSV Column Merger do?

The CSV Column Merger combines two selected columns into one single column using a customizable separator (such as a space, hyphen, underscore, slash, or custom characters). It allows in-place replacement (combining first_name and last_name into full_name) or appending the merged column as a new field while preserving RFC 4180 quotation formatting and custom delimiters.

Core Concepts

  • Concatenation with Separators: Combines values from column $A$ and column $B$ with custom punctuation or delimiters (e.g. "John" + " " + "Doe" = "John Doe").
  • Blank Value Handling: Automatically handles missing or blank fields gracefully without generating dangling or stray separators.
  • In-Place or Append Mode: Replaces both original columns in place or preserves them while appending the merged column to the spreadsheet.

How to use the tool?

  1. Input CSV Data: Paste your CSV spreadsheet data into the input box or click Load Sample.
  2. Configure Merge:
    • First & Second Column: Choose the two distinct columns to combine.
    • Separator: Select Space, Hyphen, Underscore, Slash, Comma, or enter a Custom string.
    • Merged Header: Enter the column header name (e.g. full_name).
    • Keep Original Columns: Check to append rather than replace in place.
  3. Merge & Export: Click Merge Columns, then click Copy or Download.

Related Developer Utilities

REST API Integration

blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/csv/csv-column-merger) for programmatic integration.

API Request Parameters

Name Type Description Example
rawText String Raw CSV text payload. "fname,lname\nJohn,Doe"
options Object Optional merge configurations. { "firstColIndex": 0, "secondColIndex": 1 }
options.firstColIndex Number Zero-based index of first column. 0
options.secondColIndex Number Zero-based index of second column. 1
options.separator String Separator string between merged values. " "
options.mergedHeaderName String Header name for the combined column. "full_name"
options.keepOriginals Boolean If true, appends column rather than replaces. false
options.hasHeader Boolean Whether first line is a header row. true

API Request Payload Examples

cURL

curl -X POST https://blueutils.com/api/csv/csv-column-merger \
  -H "Content-Type: application/json" \
  -d '{
    "rawText": "first_name,last_name,department\nAlice,Smith,Engineering\nBob,Jones,Marketing",
    "options": {
      "firstColIndex": 0,
      "secondColIndex": 1,
      "separator": " ",
      "mergedHeaderName": "full_name",
      "keepOriginals": false
    }
  }'

Python

import requests

url = "https://blueutils.com/api/csv/csv-column-merger"
payload = {
    "rawText": "first_name,last_name,department\nAlice,Smith,Engineering\nBob,Jones,Marketing",
    "options": {
        "firstColIndex": 0,
        "secondColIndex": 1,
        "separator": " ",
        "mergedHeaderName": "full_name"
    }
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())

Java

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String jsonPayload = "{\"rawText\": \"A,B\\n1,2\", \"options\": {\"firstColIndex\": 0, \"secondColIndex\": 1}}";
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://blueutils.com/api/csv/csv-column-merger"))
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
            .build();
        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

API Response Parameters

Name Type Description Example
isValid Boolean Indicates whether the merge operation succeeded. true
result String Resulting CSV spreadsheet text. "full_name,department\nAlice Smith,..."
mergedHeaderName String Title assigned to the merged column. "full_name"
rowCount Number Total data row count. 2
originalColumnCount Number Column count before merge. 3
finalColumnCount Number Column count after merge. 2

API Response Payload Examples

Success Response (HTTP 200 OK)

{
  "isValid": true,
  "result": "full_name,department\nAlice Smith,Engineering\nBob Jones,Marketing",
  "headers": ["full_name", "department"],
  "firstColIndex": 0,
  "secondColIndex": 1,
  "mergedHeaderName": "full_name",
  "separator": " ",
  "keepOriginals": false,
  "rowCount": 2,
  "originalColumnCount": 3,
  "finalColumnCount": 2
}

Error Response (HTTP 400 Bad Request)

{
  "isValid": false,
  "error": "Cannot merge a column with itself. Please select two distinct columns."
}

Rate Limit Exceeded Response (HTTP 429 Too Many Requests)

{
  "error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}

Why use an API to merge CSV columns?

Integrating the CSV Column Merger API into CI/CD pipelines, automated ETL pipelines, or autonomous agent workflows provides several practical advantages:

  • Rapid Script Validation: Combine address components (city, state, zip) or contact attributes (first_name, last_name) into canonical attributes prior to database synchronization.
  • Optimized Token Efficiency for AI Agents: Executing string concatenations via an API call eliminates token serialization overhead for large tables.
  • Deterministic Accuracy Without Hallucinations: Language models can skip missing cells or misalign columns when merging string columns across thousands of records. Delegating processing to a deterministic API guarantees 100% computational accuracy every time without token overhead.

Native Usage

How to achieve the same task locally without external dependencies using native operating system utilities and scripting languages:

Windows (CMD / PowerShell)

Using native PowerShell calculated properties:

# Combine first_name and last_name into full_name
Import-Csv -Path "input.csv" | Select-Object @{Name='full_name';Expression={"$($_.first_name) $($_.last_name)"}}, department | Export-Csv -Path "output.csv" -NoTypeInformation

Linux / Unix (Bash / Shell)

Using standard Linux awk:

# Combine columns 1 and 2 with space
awk -F',' 'NR==1 {print "full_name,"$3; next} {print $1" "$2","$3}' input.csv > output.csv

Python

Using the Python standard library csv module:

import csv

with open("input.csv", mode="r", encoding="utf-8") as infile:
    reader = csv.reader(infile)
    header = next(reader)
    rows = list(reader)

# Replace col 0 & 1 with merged column
new_header = ["full_name"] + header[2:]
new_rows = [[f"{row[0]} {row[1]}".strip()] + row[2:] for row in rows]

with open("output.csv", mode="w", newline="", encoding="utf-8") as outfile:
    writer = csv.writer(outfile)
    writer.writerow(new_header)
    writer.writerows(new_rows)

print("Columns merged successfully.")

Java

Using standard Java java.nio.file.Files:

import java.nio.file.*;
import java.util.*;

public class MergeCsvColumnsExample {
    public static void main(String[] args) throws Exception {
        List<String> lines = Files.readAllLines(Paths.get("input.csv"));
        if (lines.isEmpty()) return;

        List<String> output = new ArrayList<>();
        output.add("full_name," + lines.get(0).split(",", 3)[2]);

        for (int i = 1; i < lines.size(); i++) {
            String[] parts = lines.get(i).split(",", 3);
            output.add((parts[0] + " " + parts[1]).trim() + (parts.length > 2 ? "," + parts[2] : ""));
        }

        Files.write(Paths.get("output.csv"), output);
        System.out.println("Columns merged successfully.");
    }
}

Frequently Asked Questions (FAQ)

How do I merge two CSV columns online?

Paste your CSV rows into the editor, select the first and second columns to combine, pick your separator (e.g. space or hyphen), and click Merge Columns.

Can I keep the original columns when merging?

Yes. Check Keep Original Columns to append the merged column to the end of the spreadsheet rather than replacing them in place.

What happens if one of the cells is empty?

The merger automatically skips the empty value without inserting unnecessary trailing or leading separator characters.

Rate Limits

UI Limits
100 uses per 15 minutes
Max payload size: 5 MB
API Limits
5 requests per 60 minutes
Max payload size: 256 KB
Need higher API rate limits, increased payload sizes, or custom developer solutions?
Contact our engineering team at support@blueutils.com for custom rate limit increases, higher quota allocations, or tailored enterprise integrations.