# Full Name Parser: split names into first, middle and last (`loice/name-parser`) Actor

Splits full names into title, first, middle and last name, suffix and nickname. A small language model, not a rule list: handles "Last, First", particles (van der, de la, bin), double surnames, patronymics, initials, ALL CAPS and non-Latin scripts. Run it on a list or dataset, or call it as an API.

- **URL**: https://apify.com/loice/name-parser.md
- **Developed by:** [loice.ai](https://apify.com/loice) (community)
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.30 / 1,000 parsed names

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Full Name Parser: split names into first, middle and last

Turn a full name into its parts: **title, first name, middle name, last name, suffix and nickname**. Give the Actor a list of names or a dataset, or call it as a real-time API, and get one clean row per name.

| Full name                        | Title | First    | Middle     | Last           | Suffix | Nickname |
| -------------------------------- | ----- | -------- | ---------- | -------------- | ------ | -------- |
| Dr. Martin Luther King Jr.       | Dr.   | Martin   | Luther     | King           | Jr.    |          |
| García Márquez, Gabriel José     |       | Gabriel  | José       | García Márquez |        |          |
| William Jefferson "Bill" Clinton |       | William  | Jefferson  | Clinton        |        | Bill     |
| Ludwig van Beethoven             |       | Ludwig   |            | van Beethoven  |        |          |
| Ms. JANE A. DOE, MD              | Ms.   | JANE     | A.         | DOE            | MD     |          |
| Mohammed bin Salman Al Saud      |       | Mohammed | bin Salman | Al Saud        |        |          |
| Иванов Иван Иванович             |       | Иван     | Иванович   | Иванов         |        |          |

### Why use it

Most name splitters are a list of rules: "the last word is the surname". That breaks on `García Márquez`, `van der Berg`, `Smith, John` and `SMITH John`. This Actor runs a small language model that reads the whole name before it decides.

It handles:

- **Titles and suffixes**, also stacked: `Prof. Dr.`, `Lt. Col.`, `Jr.`, `III`, `PhD`, `MD`
- **"Last, First" order** and family-name-first order: `Smith, John A.`, `SMITH John`, `Иванов Иван Иванович`
- **Particles** that belong to the surname: `van der`, `de la`, `von`, `bin`, `Al-`
- **Double surnames** (`García Márquez`), hyphenated names and patronymics (`Иванович`)
- **Nicknames** in quotes or brackets: `Robert "Bob" Smith`, `John (Jack) Kennedy`
- **Initials**, including joined ones: `J.R.R. Tolkien`
- **ALL CAPS, lowercase and mixed case** input
- **Non-Latin scripts** that separate words with spaces, such as Cyrillic, Greek and Arabic
- **Romanized Chinese and Korean names**, such as `Kim Min-jun`

Each result keeps the spelling of the input. The Actor moves words into fields; it never corrects, translates or guesses a name.

#### How accurate is it

"Exact match" means every word of the name got the right label.

| Test set                    | Names | Exact match |
| --------------------------- | ----: | ----------: |
| Names from 42 countries     | 7,790 |       96.7% |
| US names                    | 1,625 |       94.2% |
| Names from many cultures    |   171 |       95.3% |

See [Limitations](#limitations) for the names the model finds hard.

### What you can do with it

- **Clean a CRM or mailing list.** Fill separate first-name and last-name columns from one "Full name" column.
- **Personalize outreach.** Greet people by first name, without "Dear Dr." or "Hi Smith,".
- **Enrich scraped data.** Chain it after a scraper whose results have a `name` or `author` field.
- **Deduplicate and match records.** Compare `Smith, John A.` and `John Smith` on the same fields.
- **Split names in real time**, in a sign-up form, an n8n or Make workflow, or an AI agent.

### How to use it

#### 1. Parse a list (input interface)

Paste the names into **Full names**, one per line, and start the run. The results are in the run's dataset, one row per name and in the same order. Download them as JSON, CSV or Excel.

```json
{
    "names": ["Dr. Martin Luther King Jr.", "García Márquez, Gabriel José"],
    "includeConfidence": true
}
```

#### 2. Parse a dataset

To parse the results of another Actor, pick its dataset in **Source dataset** and name the field that holds the full name. Turn on **Keep the source item** to get each parsed name next to the data it came from.

```json
{
    "datasetId": "YOUR_DATASET_ID",
    "nameField": "author.fullName",
    "keepSourceFields": true
}
```

Use a dataset for large jobs as well. An Actor input holds roughly 200,000 names; a dataset has no such limit.

#### 3. Call the API (server interface)

The Actor is also an HTTP API that answers at once, with no run to start or wait for. Copy the URL from the Actor's **Server** tab and send your Apify API token in the `Authorization` header.

```bash
curl -X POST "https://<ACTOR-SERVER-URL>/parse" \
  -H "Authorization: Bearer <YOUR_APIFY_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"names": ["Smith, John \"Jack\" A.", "Ludwig van Beethoven"], "confidence": true}'
```

```json
{
    "results": [
        {
            "name": "Smith, John \"Jack\" A.",
            "prefix": "",
            "first": "John",
            "middle": "A.",
            "last": "Smith",
            "suffix": "",
            "nickname": "Jack",
            "confidence": 0.9927,
            "error": null
        },
        {
            "name": "Ludwig van Beethoven",
            "prefix": "",
            "first": "Ludwig",
            "middle": "",
            "last": "van Beethoven",
            "suffix": "",
            "nickname": "",
            "confidence": 0.8782,
            "error": null
        }
    ],
    "count": 2,
    "parsed": 2
}
```

| Endpoint      | Input                                                                                |
| ------------- | ------------------------------------------------------------------------------------ |
| `POST /parse` | JSON body: `name` (string), `names` (array), optional `confidence`, `tags`           |
| `GET /parse`  | Query: `name` (repeat it for several names), optional `confidence=true`, `tags=true` |
| `GET /`       | The model version and the limits of this API                                         |

One request takes up to 1,000 names and a body of up to 2 MB. For more, split the list or start a run. Prefer `POST`: a name in a URL ends up in logs and browser history.

### Input

| Field                                        | Type    | Description                                                                       |
| -------------------------------------------- | ------- | --------------------------------------------------------------------------------- |
| `names` (Full names)                         | array   | Full names to split. One result row per name, in the same order.                  |
| `datasetId` (Source dataset)                 | string  | A dataset whose items hold a full name.                                           |
| `nameField` (Field with the full name)       | string  | The field to read from each dataset item. Dot for a nested field. Default `name`. |
| `keepSourceFields` (Keep the source item)    | boolean | Add the source dataset item to each row as `source`.                              |
| `includeConfidence` (Add a confidence score) | boolean | Add `confidence` to each row.                                                     |
| `includeTags` (Add a label for every word)   | boolean | Add `tags` to each row.                                                           |

Give `names`, `datasetId`, or both. With both, the list is parsed first.

### Output

Every row has the same fields. A part the name does not have is an empty string.

| Field        | Description                                                                                         |
| ------------ | --------------------------------------------------------------------------------------------------- |
| `name`       | The name as you gave it.                                                                            |
| `prefix`     | Title before the name: `Dr.`, `Prof. Dr.`, `Mrs.`                                                   |
| `first`      | First (given) name.                                                                                 |
| `middle`     | Middle names, second given names, patronymics and middle initials.                                  |
| `last`       | Last (family) name with its particles and second surname: `van Beethoven`, `García Márquez`.        |
| `suffix`     | Generational, academic or professional suffix: `Jr.`, `III`, `PhD`.                                 |
| `nickname`   | Nickname given in quotes or brackets.                                                               |
| `confidence` | Only when asked for. Probability from 0 to 1 that the whole split is right.                         |
| `tags`       | Only when asked for. Every word with its label, in the order of the input.                          |
| `error`      | `null`, or why the value was not parsed: `empty`, `too_long` (over 500 characters), `not_a_string`. |
| `source`     | Only with **Keep the source item**. The dataset item the name came from.                            |

A value that cannot be parsed never fails the run or the request. It comes back as a row with `error` set and empty parts, so the output always lines up with the input.

#### Use the confidence score

`confidence` is the model's own probability for the whole split. Most ordinary names score above 0.85. A low score means the name is ambiguous or is not one person's name: `Mr. and Mrs. John Smith` scores 0.38. Pick the threshold for manual review on a sample of your own data.

### Errors of the API

Errors have one shape: `{ "error": { "code": "...", "message": "..." } }`.

| Status | Code                                            | Meaning                                                          |
| ------ | ----------------------------------------------- | ---------------------------------------------------------------- |
| 400    | `invalid_json`, `invalid_body`, `missing_names` | The request is malformed or holds no name.                       |
| 404    | `not_found`                                     | Unknown path. The endpoint is `/parse`.                          |
| 405    | `method_not_allowed`                            | Use `GET` or `POST`.                                             |
| 413    | `too_many_names`, `body_too_large`              | More than one request takes. Split the list, or start a run.     |
| 503    | `billing_unavailable`                           | The request could not be billed. Nothing is returned; try again. |

A `401` or `429` comes from the Apify platform: a missing token, or more requests than your account's rate limit.

### What is charged

- A run through the input interface is charged per result row stored.
- A request to the API is charged per name that was parsed. A value that comes back with an `error` is not charged, and neither is a failed request.
- A run stops cleanly when it reaches the maximum cost you set for it. Rows stored up to then stay in the dataset.

### Limitations

- **Short East Asian names without a comma are a guess.** For two one-syllable words, such as `Wang Wei`, nothing in the name says which is the family name. Write `Wang, Wei` or `WANG Wei` when you know the order.
- **Middle name or second surname?** For a three-word name such as `María Fernanda Torres`, the middle word can be either. The model sometimes picks the surname.
- **It expects one person's name.** Couples (`Mr. and Mrs. John Smith`), company names and job titles are forced into the six fields. Use `confidence` to catch them.
- **Scripts without spaces are out of scope**: Chinese, Japanese, Korean and Thai names written without spaces.
- **It does not validate, correct or gender a name**, and it does not tell a real name from a made-up one.

### Privacy

Names are personal data, so the Actor keeps as little as it can:

- The API stores nothing. A request is parsed in memory and answered, and responses are marked `no-store`.
- The Actor never writes a name to its log. Logs hold counts, timings and error codes.
- A run stores its results only in that run's own dataset, under the data retention of the account that started it.
- No name leaves the Apify platform. The model runs inside the Actor and calls no external service.

### FAQ

**Does it use an LLM?** No. It uses a small language model that ships inside the Actor. The same input always gives the same output, and nothing is sent to a third party.

**How fast is it?** The model parses 1,000 names in about a tenth of a second. A run is limited by how fast results are written to the dataset, not by the model.

**Can I use it from n8n, Make, Zapier or an AI agent?** Yes. Use the API with any HTTP module, or your tool's Apify integration with the input above. AI agents can call the Actor through the Apify MCP server.

**The split of a name is wrong. What can I do?** Check the [Limitations](#limitations) first. If you know the order, give the name as `Last, First`. Otherwise open an issue on the Actor's **Issues** tab with the name and the split you expected.

# Actor input Schema

## `names` (type: `array`):

Full names to split, one per line. Each name gives one result row, in the same order. Any order and style works: "Dr. Martin Luther King Jr.", "García Márquez, Gabriel José", "SMITH John", "Иванов Иван Иванович". A name may be at most 500 characters.

## `datasetId` (type: `string`):

A dataset whose items hold a full name, for example the results of a scraper. Use it for lists too large for the input (above roughly 200,000 names), or to chain this Actor after another one. Leave empty when you fill in the list above.

## `nameField` (type: `string`):

The field of each dataset item that holds the full name. Use a dot for a nested field, for example "author.fullName". Used only with a source dataset.

## `keepSourceFields` (type: `boolean`):

Add the whole source dataset item to each result row as "source", so the parsed name stays next to the data it came from. Used only with a source dataset.

## `includeConfidence` (type: `boolean`):

Add "confidence" to each row: the model's probability, from 0 to 1, that the whole split is right. Use it to send low scores to a manual review.

## `includeTags` (type: `boolean`):

Add "tags" to each row: every word of the name with its label (prefix, first, middle, last, suffix or nickname), in the order the words appear.

## Actor input object example

```json
{
  "names": [
    "Dr. Martin Luther King Jr.",
    "García Márquez, Gabriel José",
    "William Jefferson \"Bill\" Clinton",
    "Ludwig van Beethoven",
    "Ms. JANE A. DOE, MD",
    "Mohammed bin Salman Al Saud"
  ],
  "nameField": "name",
  "keepSourceFields": false,
  "includeConfidence": false,
  "includeTags": false
}
```

# Actor output Schema

## `results` (type: `string`):

One item per input name, in input order: the name, its six parts (prefix, first, middle, last, suffix, nickname) and an error code or null.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "names": [
        "Dr. Martin Luther King Jr.",
        "García Márquez, Gabriel José",
        "William Jefferson \"Bill\" Clinton",
        "Ludwig van Beethoven",
        "Ms. JANE A. DOE, MD",
        "Mohammed bin Salman Al Saud"
    ],
    "nameField": "name"
};

// Run the Actor and wait for it to finish
const run = await client.actor("loice/name-parser").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "names": [
        "Dr. Martin Luther King Jr.",
        "García Márquez, Gabriel José",
        "William Jefferson \"Bill\" Clinton",
        "Ludwig van Beethoven",
        "Ms. JANE A. DOE, MD",
        "Mohammed bin Salman Al Saud",
    ],
    "nameField": "name",
}

# Run the Actor and wait for it to finish
run = client.actor("loice/name-parser").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "names": [
    "Dr. Martin Luther King Jr.",
    "García Márquez, Gabriel José",
    "William Jefferson \\"Bill\\" Clinton",
    "Ludwig van Beethoven",
    "Ms. JANE A. DOE, MD",
    "Mohammed bin Salman Al Saud"
  ],
  "nameField": "name"
}' |
apify call loice/name-parser --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,loice/name-parser"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/zavu9vGEKbNA7a4sy/builds/O01GbWYulwqXw2LmW/openapi.json
