{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://askcalculators.com/calculator/distance-calculator/schema.json",
  "title": "Distance Calculator inputs",
  "description": "Calculate distance in 2D, 3D, or between two latitude/longitude coordinates on Earth.",
  "type": "object",
  "properties": {
    "mode": {
      "title": "Distance model",
      "type": "string",
      "default": "2d",
      "enum": [
        "2d",
        "3d",
        "geographic"
      ],
      "x-optionLabels": {
        "2d": "2D coordinates",
        "3d": "3D coordinates",
        "geographic": "Latitude and longitude"
      }
    },
    "x1": {
      "title": "x₁",
      "type": "number",
      "default": 0,
      "x-step": 0.01,
      "x-showWhen": {
        "field": "mode",
        "equals": "2d"
      }
    },
    "y1": {
      "title": "y₁",
      "type": "number",
      "default": 0,
      "x-step": 0.01,
      "x-showWhen": {
        "field": "mode",
        "equals": "2d"
      }
    },
    "x2": {
      "title": "x₂",
      "type": "number",
      "default": 3,
      "x-step": 0.01,
      "x-showWhen": {
        "field": "mode",
        "equals": "2d"
      }
    },
    "y2": {
      "title": "y₂",
      "type": "number",
      "default": 4,
      "x-step": 0.01,
      "x-showWhen": {
        "field": "mode",
        "equals": "2d"
      }
    },
    "x1Three": {
      "title": "x₁",
      "type": "number",
      "default": 0,
      "x-step": 0.01,
      "x-showWhen": {
        "field": "mode",
        "equals": "3d"
      }
    },
    "y1Three": {
      "title": "y₁",
      "type": "number",
      "default": 0,
      "x-step": 0.01,
      "x-showWhen": {
        "field": "mode",
        "equals": "3d"
      }
    },
    "z1Three": {
      "title": "z₁",
      "type": "number",
      "default": 0,
      "x-step": 0.01,
      "x-showWhen": {
        "field": "mode",
        "equals": "3d"
      }
    },
    "x2Three": {
      "title": "x₂",
      "type": "number",
      "default": 3,
      "x-step": 0.01,
      "x-showWhen": {
        "field": "mode",
        "equals": "3d"
      }
    },
    "y2Three": {
      "title": "y₂",
      "type": "number",
      "default": 4,
      "x-step": 0.01,
      "x-showWhen": {
        "field": "mode",
        "equals": "3d"
      }
    },
    "z2Three": {
      "title": "z₂",
      "type": "number",
      "default": 12,
      "x-step": 0.01,
      "x-showWhen": {
        "field": "mode",
        "equals": "3d"
      }
    },
    "latitude1": {
      "title": "Latitude 1",
      "type": "number",
      "default": 40.7128,
      "minimum": -90,
      "maximum": 90,
      "x-step": 0.000001,
      "x-showWhen": {
        "field": "mode",
        "equals": "geographic"
      }
    },
    "longitude1": {
      "title": "Longitude 1",
      "type": "number",
      "default": -74.006,
      "minimum": -180,
      "maximum": 180,
      "x-step": 0.000001,
      "x-showWhen": {
        "field": "mode",
        "equals": "geographic"
      }
    },
    "latitude2": {
      "title": "Latitude 2",
      "type": "number",
      "default": 51.5074,
      "minimum": -90,
      "maximum": 90,
      "x-step": 0.000001,
      "x-showWhen": {
        "field": "mode",
        "equals": "geographic"
      }
    },
    "longitude2": {
      "title": "Longitude 2",
      "type": "number",
      "default": -0.1278,
      "minimum": -180,
      "maximum": 180,
      "x-step": 0.000001,
      "x-showWhen": {
        "field": "mode",
        "equals": "geographic"
      }
    }
  },
  "required": [
    "mode"
  ],
  "allOf": [
    {
      "if": {
        "properties": {
          "mode": {
            "const": "2d"
          }
        },
        "required": [
          "mode"
        ]
      },
      "then": {
        "required": [
          "x1"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "mode": {
            "const": "2d"
          }
        },
        "required": [
          "mode"
        ]
      },
      "then": {
        "required": [
          "y1"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "mode": {
            "const": "2d"
          }
        },
        "required": [
          "mode"
        ]
      },
      "then": {
        "required": [
          "x2"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "mode": {
            "const": "2d"
          }
        },
        "required": [
          "mode"
        ]
      },
      "then": {
        "required": [
          "y2"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "mode": {
            "const": "3d"
          }
        },
        "required": [
          "mode"
        ]
      },
      "then": {
        "required": [
          "x1Three"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "mode": {
            "const": "3d"
          }
        },
        "required": [
          "mode"
        ]
      },
      "then": {
        "required": [
          "y1Three"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "mode": {
            "const": "3d"
          }
        },
        "required": [
          "mode"
        ]
      },
      "then": {
        "required": [
          "z1Three"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "mode": {
            "const": "3d"
          }
        },
        "required": [
          "mode"
        ]
      },
      "then": {
        "required": [
          "x2Three"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "mode": {
            "const": "3d"
          }
        },
        "required": [
          "mode"
        ]
      },
      "then": {
        "required": [
          "y2Three"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "mode": {
            "const": "3d"
          }
        },
        "required": [
          "mode"
        ]
      },
      "then": {
        "required": [
          "z2Three"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "mode": {
            "const": "geographic"
          }
        },
        "required": [
          "mode"
        ]
      },
      "then": {
        "required": [
          "latitude1"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "mode": {
            "const": "geographic"
          }
        },
        "required": [
          "mode"
        ]
      },
      "then": {
        "required": [
          "longitude1"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "mode": {
            "const": "geographic"
          }
        },
        "required": [
          "mode"
        ]
      },
      "then": {
        "required": [
          "latitude2"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "mode": {
            "const": "geographic"
          }
        },
        "required": [
          "mode"
        ]
      },
      "then": {
        "required": [
          "longitude2"
        ]
      }
    }
  ],
  "additionalProperties": false,
  "x-askcalculators": {
    "version": "2.0.0",
    "calculatorUrl": "https://askcalculators.com/calculator/distance-calculator/",
    "queryExample": "https://askcalculators.com/calculator/distance-calculator/?mode=2d&x1=0&y1=0&x2=3&y2=4",
    "migrationStatus": "migrated",
    "reviewStatus": "pending",
    "pageStatus": "live",
    "workStatus": "pending",
    "migratedDate": "2026-08-25",
    "formula": {
      "expression": "Cartesian: d=√[Σ(qᵢ−pᵢ)²]; geographic: d=2R·asin(√[sin²(Δφ/2)+cosφ₁cosφ₂sin²(Δλ/2)])."
    },
    "quality": {
      "availability": "live",
      "technicalReviewRecord": "/reviews/distance-calculator.json",
      "qualifiedReview": "pending",
      "qualifiedReviewer": null,
      "qualifiedReviewDate": null,
      "formulaVersion": "2.0.0",
      "referenceCoverage": "references-listed",
      "releaseTestScope": "Catalog and regression checks are not a professional formula audit; consult release evidence.",
      "historicalMetadataDate": "2026-08-25",
      "historicalMetadataNotice": "The imported date is not evidence of a completed human review."
    },
    "outputs": {
      "distance": {
        "title": "Distance",
        "type": "number",
        "x-format": "number",
        "x-digits": 6,
        "x-primary": true
      },
      "distanceKilometers": {
        "title": "Distance",
        "type": "number",
        "x-format": "number",
        "x-suffix": " km",
        "x-digits": 3
      },
      "distanceMiles": {
        "title": "Distance",
        "type": "number",
        "x-format": "number",
        "x-suffix": " mi",
        "x-digits": 3
      },
      "deltaX": {
        "title": "Δx",
        "type": "number",
        "x-format": "number",
        "x-digits": 6
      },
      "deltaY": {
        "title": "Δy",
        "type": "number",
        "x-format": "number",
        "x-digits": 6
      },
      "deltaZ": {
        "title": "Δz",
        "type": "number",
        "x-format": "number",
        "x-digits": 6
      },
      "initialBearing": {
        "title": "Initial bearing",
        "type": "number",
        "x-format": "number",
        "x-suffix": "°",
        "x-digits": 3
      },
      "midpoint": {
        "title": "Midpoint",
        "type": "string",
        "x-format": "text"
      }
    }
  }
}
