Continue → Overview
← All notes

First, middle and last name from any full name, in the same lookup

5 min read api parsing guide

Every NameGender lookup now returns the input split into first_name, middle_name and last_name, at no extra cost. The fields come back from the API, in spreadsheet results and in the n8n node, and they are filled in even when the gender is unknown. If you were splitting names in your own code before sending them, you can stop.

Here is a real response for an input written surname first:

{
  "query": "Smith, John",
  "name": "John",
  "first_name": "John",
  "middle_name": null,
  "last_name": "Smith",
  "name_type": "personal",
  "gender": "male",
  "probability": 100,
  "sample_size": 554573,
  "confidence": "high",
  "source": "db"
}

What the split looks like

Input Country first_name middle_name last_name
Dr. Ayşe Yılmaz Ayşe Yılmaz
John Fitzgerald Kennedy John Fitzgerald Kennedy
John F. Kennedy John Kennedy
Smith, John John Smith
John Smith, Jr. John Smith
Ludwig van Beethoven Ludwig van Beethoven
Juan de la Cruz ES Juan de la Cruz
Juan Pérez García ES Juan Pérez García
Juan Pérez García none Juan Pérez García
王小明 小明
김민준 민준
J. Smith Smith

The same rules apply to email addresses: john.doe@example.com gives John and Doe.

The rules

Titles and initials are dropped. "Dr.", "Mrs" and "Prof." are never returned, and neither is a single initial like the F. in John F. Kennedy. An initial is not a name, and returning it in middle_name would put a letter where a CRM expects a word.

A comma means surname first. "Smith, John" and "Yılmaz, Ayşe" are common in exported customer lists. A trailing ", Jr." or ", PhD" is recognised as a suffix, not as a surname.

Particles stay with the surname. "van", "von", "de la", "bin" and similar words join the last name when they come before it, so Ludwig van Beethoven keeps "van Beethoven" together. A particle on its own is still a surname: Mary Le has the last name Le.

A Spanish-speaking country hint means two surnames. In Spain and most of Latin America, people carry a paternal and a maternal surname, so with country=ES or country=MX the last two words both go into last_name. Without a country, only the last word does.

Chinese and Korean script put the surname first. 王小明 splits into the surname 王 and the given name 小明; two-character surnames such as 欧阳 are recognised. A two-syllable Korean name like 서연 is treated as a given name on its own, because that is how Korean given names are usually written.

Usernames never return a surname. A handle like kevin_gamer has the same shape as jane_doe, and there is no way to tell which second word is a surname. Only first_name is filled for usernames.

Why it uses the same rule as the lookup

The name field has always shown the first name that was actually looked up. first_name comes from the same step, so the two can never disagree: if the gender answer is for John, first_name is John.

Building this surfaced a lookup bug that is now fixed. "Smith, John" used to be looked up as Smith, so any list exported surname first got the gender of each surname rather than each first name.

Where splitting fails

Name splitting has no rule that is right in every language, so these cases are known and deliberate:

  • "Juan Carlos Pérez" with a Spanish-speaking country splits into Juan and "Carlos Pérez", because the two-surname rule cannot tell a compound first name from a surname.
  • Japanese names written without a space are not split. 山田太郎 could be 山/田太郎 or 山田/太郎, and the script alone does not say which, so all three fields come back empty rather than wrong. 山田 太郎 with a space splits correctly.
  • Romanised East Asian names such as "Wang Xiaoming" are read first name first, because exported lists use both orders.
  • Hungarian names, which put the surname first in Latin script, are read first name first.

If your data has one of these patterns, send the fields you already have separately instead of a full name.

In spreadsheet results

Uploaded CSV and XLSX files get first_name, middle_name and last_name columns next to the gender columns. They are filled row by row from each cell, so two customers who share a first name keep their own surnames. The spreadsheet walkthrough lists every column.

Frequently asked questions

Does splitting a name cost an extra credit? No. A lookup costs one credit, and the name parts are part of the same response.

Do the name fields come back when the gender is unknown? Yes. Splitting does not depend on the gender result, so a name the dataset does not know still gets its first and last name.

What happens with company names? Inputs such as "Acme LLC" are recognised as organisations and return no name parts and no gender. See how name_type works.

How do I split a full name into first and last name with an API? Send the full name to POST /api/v1/gender and read first_name, middle_name and last_name from the response. Add a country code when you know it, because it changes how surnames are read. The API documentation lists every field.

Every claim on this page is measurable against your own list. The free tier is enough to check it.