Skip to content

Load GEDCOM Data in Family Tree JS 2

Code example: Load GEDCOM Data in Family Tree JS 2

Family Tree JS 2 supports importing GEDCOM files directly into your family tree using the FamilyTree2.convertGedcomToFamilyMembers() method.

javascript
FamilyTree2.convertGedcomToFamilyMembers(text, fieldBinding)

Parameters:

  • text: The raw GEDCOM file content as a string.
  • fieldBinding: Maps GEDCOM tag names to your family tree node property names.

Example mapping:

javascript
{
  NAME: 'name', // GEDCOM "NAME" -> node.name
  BIRT_DATE: 'dateOfBirth' // GEDCOM "1 BIRT 2 DATE" -> node.dateOfBirth
}

Workflow

  1. Open a GEDCOM file: Use the File System Access API with showOpenFilePicker() to let the user choose a .ged file, then read its content as text.
  2. Convert to Family Members: Pass the GEDCOM text and your field mapping into convertGedcomToFamilyMembers().
  3. Display in Family Tree: Use addFamilyMembers() and draw() to render the tree.