{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://pededit.com/docs/pedigree-json-schema.json",
  "title": "PedEdit pedigree JSON document",
  "description": "Lossless JSON export of a PedEdit pedigree. The document root is the envelope; the importer also accepts a bare Pedigree object. See docs/pedigree-json-format.md.",
  "type": "object",
  "required": ["format", "version", "pedigree"],
  "properties": {
    "format": { "const": "pededit-pedigree" },
    "version": { "type": "integer", "minimum": 1 },
    "exportedAt": { "type": "string", "format": "date-time" },
    "title": { "type": "string" },
    "pedigree": { "$ref": "#/$defs/Pedigree" }
  },
  "$defs": {
    "Pedigree": {
      "type": "object",
      "required": ["individuals", "partnerships", "parentOf"],
      "properties": {
        "individuals": { "type": "array", "items": { "$ref": "#/$defs/Individual" } },
        "partnerships": { "type": "array", "items": { "$ref": "#/$defs/Partnership" } },
        "parentOf": {
          "type": "object",
          "description": "Keys are partnership ids, values are the ids of that partnership's children.",
          "additionalProperties": { "type": "array", "items": { "type": "string" } }
        },
        "siblingOrder": { "$ref": "#/$defs/SiblingOrderSettings" },
        "pinnedPositions": {
          "type": "object",
          "description": "Manual drag overrides keyed by individual id, in canvas pixels.",
          "additionalProperties": {
            "type": "object",
            "required": ["x", "y"],
            "properties": { "x": { "type": "number" }, "y": { "type": "number" } }
          }
        },
        "canvasSettings": { "$ref": "#/$defs/CanvasSettings" },
        "unlockedIndividuals": { "type": "array", "items": { "type": "string" } },
        "tags": {
          "type": "array",
          "description": "Tag definitions in display order. Quadrant tags take their sector from this order.",
          "items": { "$ref": "#/$defs/Tag" }
        },
        "chartTitle": {
          "type": "string",
          "description": "Title drawn above the chart and in exports. Absent means the pedigree's name; an empty string means no title."
        },
        "clinicalDetails": { "$ref": "#/$defs/ClinicalDetails" },
        "filters": { "$ref": "#/$defs/ViewFilters" }
      },
      "additionalProperties": true
    },
    "Individual": {
      "type": "object",
      "required": ["id", "sex", "affected", "sibOrder"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "sex": { "enum": ["male", "female", "unknown"], "description": "Biological sex (sex assigned at birth). Used by the layout and every genetic calculation." },
        "genderIdentity": {
          "enum": ["man", "woman", "nonbinary"],
          "description": "Gender identity (NSGC 2022). With CanvasSettings.symbolsShow \"gender\" (the default) the symbol shows it, with AMAB, AFAB or UAAB below. Ignored for pregnancies and losses."
        },
        "affected": { "type": "boolean" },
        "deceased": { "type": "boolean" },
        "carrier": { "type": "boolean", "description": "Carrier with no condition recorded: the centre dot (nsgc2008) or the right half of the symbol dotted (nsgc2022). A carrier of a named condition is in carrierTags instead." },
        "presymptomatic": { "type": "boolean", "description": "Asymptomatic or presymptomatic carrier (NSGC): a vertical line through the symbol. The editor never sets it together with carrier." },
        "evaluations": {
          "type": "array",
          "description": "Evaluations and test results (NSGC), written under the symbol as the detail then the result (\"BRCA1 c.5266dupC +\"), or with CanvasSettings.notation \"nsgc2008\" as E+ (detail), numbered E1, E2 when there are several.",
          "items": { "$ref": "#/$defs/Evaluation" }
        },
        "proband": { "type": "boolean", "description": "Proband arrow with a P (NSGC). Normally exactly one individual." },
        "consultand": { "type": "boolean", "description": "Consultand arrow, without the P (NSGC): the person seeking counselling. Someone who is also the proband is drawn as the proband." },
        "familyHistoryUnknown": { "type": "boolean", "description": "Family history not known (NSGC): a ? above the symbol." },
        "lifeStatus": {
          "enum": ["pregnancy", "miscarriage", "termination", "stillbirth", "ectopic"],
          "description": "Pregnancy or pregnancy loss. Absent means born. Such an individual has no partners or children."
        },
        "adopted": {
          "enum": ["in", "out"],
          "description": "Adoption brackets round the symbol (NSGC). \"in\": adopted into the family shown, dashed line to the adoptive parents. \"out\": placed for adoption, solid line to the biological parents."
        },
        "reproductiveRole": {
          "enum": ["donor", "surrogate"],
          "description": "Assisted reproduction (NSGC): \"donor\" draws D inside the symbol (sperm or egg donor), \"surrogate\" draws S (a woman who carried a pregnancy she is not the genetic mother of)."
        },
        "carriedBy": { "type": "string", "description": "Id of the woman who carried this pregnancy when she is not the genetic mother (a surrogate, or the mother of a child conceived with a donor egg). Solid line from her to the child; not a parent for kinship or PED." },
        "socialParents": { "type": "array", "items": { "type": "string" }, "description": "Ids of parents who are not genetic parents, such as the intended father when donor sperm is used. Dashed line to the child; not parents for kinship or PED." },
        "sibOrder": { "type": "number", "description": "0-indexed position within the sibling group." },
        "name": { "type": "string" },
        "dob": { "type": "string", "description": "ISO date, YYYY-MM-DD." },
        "dod": { "type": "string", "pattern": "^[0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?$", "description": "Date of death: YYYY-MM-DD, YYYY-MM or YYYY. Drawn only when deceased is true." },
        "age": { "type": "string", "description": "The individual's age as free text, e.g. \"50s\" or \"d. 72\", shown under the symbol in place of the DOB. Not an age of onset." },
        "notes": { "type": "string" },
        "hpoTerms": { "type": "array", "items": { "type": "string", "pattern": "^HP:[0-9]{7}$" } },
        "descendantsHidden": { "type": "boolean", "description": "Everyone below this individual is left out of the drawing and exports (not removed from the data)." },
        "placeholder": { "type": "boolean", "description": "Made automatically as the second parent of a child given only one; removed with its couple line when the couple loses its last child, while nothing else is recorded about them." },
        "tags": { "type": "array", "items": { "type": "string" }, "description": "Ids of tags from Pedigree.tags applied to this individual. A quadrant (condition) tag here means affected with that condition." },
        "carrierTags": { "type": "array", "items": { "type": "string" }, "description": "Ids of quadrant (condition) tags this individual is a carrier of: the condition's sector is drawn with its carrier pattern and keyed \"<condition> carrier\". A tag is in tags or carrierTags, not both (both counts as affected). Ids of other tag styles are ignored." },
        "onset": { "type": "string", "description": "Age of onset of the affected status, free text such as \"45y\" or \"40s\". Used only while affected is true." },
        "tagOnset": {
          "type": "object",
          "description": "Age of onset per condition: id of a quadrant tag this individual carries, to free text as for onset.",
          "additionalProperties": { "type": "string" }
        }
      },
      "additionalProperties": true
    },
    "Partnership": {
      "type": "object",
      "required": ["id", "individual1", "individual2"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "individual1": { "type": "string" },
        "individual2": { "type": "string" },
        "consanguineous": { "type": "boolean" },
        "consanguinityLabel": { "type": "string", "description": "Text written above the double line, e.g. third cousins: the degree of relationship when the drawing does not show it. Drawn only when the line is double." },
        "childless": {
          "enum": ["infertility", "byChoice"],
          "description": "Childless couple mark under the couple line (NSGC): two bars for infertility, one bar for no children by choice. Only on a partnership with no children."
        },
        "childlessReason": { "type": "string", "description": "Optional reason shown under the childless mark, e.g. vasectomy." },
        "twins": {
          "type": "array",
          "description": "Twin sets among this partnership's children. Each member is in at most one set.",
          "items": { "$ref": "#/$defs/TwinSet" }
        },
        "ended": { "type": "boolean", "description": "The relationship no longer exists (separated, divorced): two short strokes across the couple line." },
        "leftPartner": { "type": "string", "description": "Id of the partner drawn on the left of this couple: individual1 or individual2. Absent means the layout chooses." },
        "drawnBeside": { "type": "string", "description": "Id of the partner this couple is drawn beside: individual1 or individual2. In a family with a loop the other partner is then the one drawn twice. Absent means the layout chooses." },
        "donorConception": { "type": "boolean", "description": "The children were conceived with a donated sperm or egg: the partners are the genetic parents but not a couple, so no couple line is drawn and each partner's line runs to the children (NSGC)." }
      },
      "additionalProperties": true
    },
    "Evaluation": {
      "type": "object",
      "properties": {
        "result": { "enum": ["positive", "negative", "uninformative"], "description": "+, - or u after the E. Absent: no result recorded." },
        "detail": { "type": "string", "description": "Short text shown in parentheses, e.g. BRCA1 c.5266dupC." },
        "documented": { "type": "boolean", "description": "Documented evaluation: a * at the symbol's lower right." }
      },
      "additionalProperties": true
    },
    "TwinSet": {
      "type": "object",
      "required": ["members", "zygosity"],
      "properties": {
        "members": { "type": "array", "minItems": 2, "items": { "type": "string" }, "description": "Ids of children of the partnership, in drawing order." },
        "zygosity": { "enum": ["monozygotic", "dizygotic", "unknown"], "description": "Monozygotic members must have the same sex." }
      },
      "additionalProperties": true
    },
    "Tag": {
      "type": "object",
      "required": ["id", "label", "color", "style"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "label": { "type": "string", "description": "Full name shown in the legend." },
        "color": { "type": "string", "description": "CSS colour, normally #rrggbb." },
        "style": { "enum": ["quadrant", "dot", "text"] },
        "abbrev": { "type": "string", "description": "Short canvas text for text-style tags. Defaults to label." },
        "fill": {
          "enum": ["solid", "horizontal", "vertical", "diagonal", "crosshatch", "dots", "shade"],
          "description": "How a quadrant tag fills its sector: solid in the tag's colour, or a pattern drawn in the tag's colour on white (horizontal or vertical lines, diagonal hatching, cross-hatching, dots), or a light tint of the colour (shade). Absent means \"solid\". Ignored for dot and text tags."
        },
        "kind": {
          "enum": ["condition", "trait"],
          "description": "What a quadrant tag means. Absent or \"condition\": a condition, the people with it affected with it (or carriers, carrierTags). \"trait\": a coloured section only, saying nothing about affected status. Ignored for dot and text tags."
        }
      },
      "additionalProperties": true
    },
    "SiblingOrderSettings": {
      "type": "object",
      "required": ["mode", "affectedFirst"],
      "properties": {
        "mode": { "enum": ["insertion", "manual", "birthDate"] },
        "affectedFirst": { "type": "boolean" }
      }
    },
    "ClinicalDetails": {
      "type": "object",
      "description": "Clinical key fields (NSGC 2008, Fig. 1 instructions). All free text; absent or empty means not recorded. Shown in the key when filled; de-identified exports drop them.",
      "properties": {
        "referralReason": { "type": "string", "description": "Reason for taking the pedigree." },
        "recordedBy": { "type": "string", "description": "Who drew the pedigree." },
        "recordedOn": { "type": "string", "description": "Date of intake or last update, normally ISO YYYY-MM-DD." },
        "historian": { "type": "string", "description": "Who gave the family history." },
        "maternalAncestry": { "type": "string", "description": "Ancestry of the maternal side, relative to the proband." },
        "paternalAncestry": { "type": "string", "description": "Ancestry of the paternal side, relative to the proband." }
      },
      "additionalProperties": true
    },
    "ViewFilters": {
      "type": "object",
      "description": "View filters: simplify what is drawn (canvas and SVG, PNG, PDF exports) without changing the data. Each is off when absent.",
      "properties": {
        "affectedOnly": { "type": "boolean", "description": "Draw only affected people, carriers, people with a condition tag and the proband (and consultand), with their ancestors. Each drawn couple's other children are drawn as one symbol with their number inside." },
        "affectedCondition": { "type": "string", "description": "With affectedOnly: the id of a condition tag; only people affected with or carrying it (and the proband and consultand) start the filter. Ignored when it names no condition tag." },
        "bloodRelativesOnly": { "type": "boolean", "description": "Draw only the proband's (or consultand's) blood relatives and their partners. The families of people who married in are not drawn." },
        "side": { "enum": ["maternal", "paternal"], "description": "Draw only the proband's (or consultand's) mother's or father's blood relatives and their partners, and the proband. The other parent is drawn, their family is not." }
      },
      "additionalProperties": true
    },
    "CanvasSettings": {
      "type": "object",
      "required": ["nodesMoveable", "snapToGrid", "snapGridSize"],
      "properties": {
        "nodesMoveable": { "type": "boolean" },
        "snapToGrid": { "type": "boolean" },
        "snapGridSize": { "type": "number" },
        "nameLabels": {
          "enum": ["wrap", "truncate"],
          "description": "How a name too long for its slot is shown on the canvas: wrapped onto two lines, or cut to one line. Absent means \"wrap\". Exports always wrap."
        },
        "layoutWidth": {
          "enum": ["minimal", "relaxed"],
          "description": "How wide the automatic layout may be: no wider than the widest generation, or up to two slots wider so children sit more directly under their parents. Absent means \"minimal\". Applies to the canvas and to exports."
        },
        "showNumbers": {
          "type": "boolean",
          "description": "Draw each person's pedigree number (generation in Roman numerals, then place in the row, e.g. \"II-3\") before their name, on the canvas and in figure exports. The numbers are computed from the layout, not stored. Absent means false."
        },
        "relationshipLabels": {
          "type": "boolean",
          "description": "Write the relationship (e.g. \"first cousins\") above every consanguineous couple's double line that can be named and has no consanguinityLabel of its own. Absent means false."
        },
        "showCoefficients": {
          "type": "boolean",
          "description": "Draw the inbreeding coefficient under anyone whose parents are related (\"F = 1/16\") and the kinship coefficient above a related couple's double line (\"\u03c6 = 1/16\"), on the canvas and in figure exports. The coefficients are computed from the pedigree, not stored. Absent means false."
        },
        "symbolsShow": {
          "enum": ["gender", "sex"],
          "description": "What symbol shapes show: \"gender\" draws someone with a recorded genderIdentity with that gender's symbol and their sex assigned at birth (AMAB, AFAB, UAAB) below it (NSGC 2022); \"sex\" draws biological sex for everyone. Absent means \"gender\"."
        },
        "notation": {
          "enum": ["nsgc2022", "nsgc2008"],
          "description": "Edition of the NSGC pedigree nomenclature drawn. \"nsgc2022\" writes evaluation results under the symbol as the detail then the result (\"BRCA1 c.5266dupC +\"); \"nsgc2008\" uses the E notation (\"E+ (BRCA1 c.5266dupC)\", numbered E1, E2 when there are several), and draws a carrier with no condition recorded as the centre dot instead of the dotted right half. Absent means \"nsgc2008\", so pedigrees saved before the setting existed keep their look; new pedigrees, PED imports and the built-in examples are written with \"nsgc2022\"."
        },
        "tagFills": {
          "enum": ["color", "monochrome"],
          "description": "\"monochrome\" draws every tag in black, on the canvas and in figure exports, and each quadrant tag with a pattern: its own fill, or, when that is solid, the first of diagonal, horizontal, dots, crosshatch, shade, vertical that no other quadrant tag has. Absent means \"color\"."
        }
      }
    }
  },
  "examples": [
    {
      "format": "pededit-pedigree",
      "version": 1,
      "exportedAt": "2026-11-06T09:30:00.000Z",
      "title": "Example family",
      "pedigree": {
        "individuals": [
          { "id": "i1", "sex": "male", "affected": false, "sibOrder": 0, "name": "John" },
          { "id": "i2", "sex": "female", "affected": false, "sibOrder": 0, "name": "Mary", "dob": "1952-03-14" },
          { "id": "i3", "sex": "female", "affected": true, "proband": true, "sibOrder": 0, "hpoTerms": ["HP:0001250"] },
          { "id": "i4", "sex": "male", "affected": false, "deceased": true, "sibOrder": 1, "notes": "Died in infancy" }
        ],
        "partnerships": [
          { "id": "p1", "individual1": "i1", "individual2": "i2" }
        ],
        "parentOf": {
          "p1": ["i3", "i4"]
        },
        "siblingOrder": { "mode": "insertion", "affectedFirst": false },
        "pinnedPositions": { "i3": { "x": 180, "y": 240 } },
        "canvasSettings": { "nodesMoveable": false, "snapToGrid": true, "snapGridSize": 20 },
        "unlockedIndividuals": ["i3"]
      }
    }
  ]
}
