Skip to content

GEDCOM

The FamilyTree2.convertGedcomToFamilyMembers() method allows you to import GEDCOM file data directly into Family Tree JS 2 and display it as a family tree.

javascript
FamilyTree2.convertGedcomToFamilyMembers(text, fieldBinding)
  • text is the raw GEDCOM file content as a string.
  • fieldBinding is an object that maps GEDCOM tag names to your family tree node property names.
javascript
{
  NAME: 'name',
  BIRT_DATE: 'dateOfBirth'
}

NAME maps the GEDCOM NAME tag to the node name property.

BIRT_DATE maps the GEDCOM 1 BIRT 2 DATE tag to the node dateOfBirth property.

Load GEDCOM Data

Here is an example workflow for loading GEDCOM data:

  1. Open a GEDCOM file with the File System Access API.
  2. Convert the file content into family members.
  3. Load the converted data into the tree.

1. Open a GEDCOM File

Use showOpenFilePicker() to let the user choose a .ged file, then read the file as text.

2. Convert GEDCOM to Family Members

javascript
let familyMembers = FamilyTree2.convertGedcomToFamilyMembers(text, fieldBinding);

3. Load into the Family Tree

javascript
familyTree.addFamilyMembers(familyMembers).draw(familyMembers[0].id);

Full Code Example

Load GEDCOM Data in Family Tree JS 2

This example demonstrates:

  • Opening a .ged file.
  • Mapping GEDCOM fields with fieldBinding.
  • Converting the data with convertGedcomToFamilyMembers().
  • Displaying the converted data in a family tree.