Skip to main content
← Back to Blog

How to use CleanTextLab in n8n Workflows

3 min read

How to use CleanTextLab in n8n Workflows

n8n is one of the most powerful workflow automation tools available. Whether you're self-hosting it or using their cloud version, it excels at connecting different apps together.

But often, the data moving between those apps is messy.

  • User-submitted names in ALL CAPS.
  • Phone numbers with weird formatting (+1 (555) ... vs 555-...).
  • Lists containing duplicate email addresses.

This is where integrating CleanTextLab into your n8n workflow can save you hours of writing custom JavaScript functions.

In this guide, we'll show you how to clean your data automatically using the CleanTextLab API and the standard n8n HTTP Request node.


Prerequisites

  1. An active n8n instance (Cloud or Self-Hosted).
  2. A CleanTextLab Pro account (to get your API key).

Step 1: Get your API Key

If you haven't already, sign up for CleanTextLab Pro. Once you're signed in:

  1. Go to the Settings page (or check your email receipt).
  2. Copy your Pro API Key. It looks like clt_....

Step 2: Add the HTTP Request Node

In your n8n canvas:

  1. Click the + button to add a node.
  2. Search for HTTP Request.
  3. Select it to add it to your workflow.

Step 3: Configure the Node

We're going to set up the node to call the new Headless API to sort and deduplicate a list, but you can chain multiple tools (like "remove-all-spaces" -> "sort-remove-duplicates") in a single request!

  • Method: POST
  • URL: https://cleantextlab.com/api/v1/run
  • Authentication: Generic Credential Type -> Header Auth (or just add headers manually).

Setting the Headers manually (Easiest way)

Scroll down to Headers and add a new parameter:

  • Name: x-api-key
  • Value: YOUR_COPIED_API_KEY

Setting the Body

  1. Set Send Body to true.
  2. Set Content Type to JSON.
  3. In the Body Parameters, add your input data and the steps you want to run.

Example JSON Body:

{
  "input": "apple\nbanana\napple\norange\nBANANA",
  "steps": [
    {
      "toolSlug": "sort-remove-duplicates",
      "options": {
        "insensitive": true
      }
    }
  ]
}

Pro Tip: You can chain tools! Add { "toolSlug": "remove-all-spaces" } (or just "remove-all-spaces") before the sort step.

Step 4: Test the Workflow

Click Execute Node.

You should receive a JSON response back instantly:

{
  "result": "apple\nbanana\norange",
  "meta": {
    "stepsExecuted": 1,
    "inputLength": 32,
    "outputLength": 20
  }
}

Now you can map result into your next node (e.g., adding it to a HubSpot CRM or sending a Slack notification).


Top Use Cases for n8n + CleanTextLab

1. Cleaning Web Scraper Data

If you scrape data using n8n, you often end up with duplicate URLs or "dirty" strings with extra whitespace.

  • Steps: ["sanitize-url", "sort-remove-duplicates"]
  • Result: Clean, unique lists ready for your database.

2. Normalizing User Input

When users fill out Typeforms or Webhooks, they might type "JOHN DOE" or "john doe".

  • Steps: ["title-case-converter"]
  • Result: Professional "John Doe" formatting before it hits your email marketing tool.

3. Formatting Phone Numbers

Standardize diverse phone number formats (555.123.4567) into a standard format ((555) 123-4567) for consistency.

  • Steps: ["phone-number-formatter"]

Ready to automate your text cleaning? Grab your API Key and start building!

Try the tools mentioned

Jump straight into the most relevant tools for this post.

Share this post