← All tools

JSON → PySpark Schema Converter

Paste a JSON object or an array of objects and get a ready-to-use PySpark StructType, plus Spark SQL DDL, a SQL CREATE TABLE, and a Delta Lake table definition. Nested structs, arrays, nulls, and int/float promotion are all handled.

Your JSON never leaves your browser

Paste JSON below, or drop a .json file here.

About this JSON to PySpark schema converter

When you ingest JSON into Spark, Databricks, or Microsoft Fabric, letting the engine infer the schema on every run is slow and fragile — the recommended practice is to define an explicit schema. Hand-writing a PySpark StructType for a deeply nested payload is tedious and error-prone, so this tool does it for you. Paste a JSON object or an array of objects and it infers a single merged schema across all the elements, then emits four ready-to-paste outputs: a PySpark StructType (with the matching from pyspark.sql.types import ... line), a Spark SQL DDL string, a T-SQL CREATE TABLE, and a Delta Lake CREATE TABLE ... USING DELTA statement.

It handles the things that make schema inference annoying: nested structs, arrays, arrays of structs, fields that are sometimes missing or null (marked nullable=True), and columns that mix integers and floats (promoted to double). ISO date and timestamp strings are detected automatically, with a toggle to keep them as StringType if you'd rather parse them downstream. Everything runs in your browser — the JSON is never uploaded — so it's safe for internal or production payloads.

FAQ

How do I convert JSON to a PySpark StructType?

Paste your JSON (a single object, or an array of objects for better inference) and click Convert. Copy the generated StructType and the import line into your PySpark job, then pass the schema to spark.read.schema(schema).json(...).

Does it handle nested objects and arrays of structs?

Yes. Nested objects become nested StructTypes, JSON arrays become ArrayType, and arrays of objects become ArrayType(StructType([...])). Field types are merged across every element of an input array.

How is nullability decided?

A field is marked nullable if it's ever null, or missing from some objects in an input array, or if it mixes incompatible types. When in doubt the converter is conservative and marks the field nullable, which is the safe default for Spark.

Is my JSON sent to a server?

No. All parsing and schema inference runs locally in your browser with plain JavaScript. Nothing is uploaded, logged, or stored.

Independent community tool — not affiliated with Apache Spark, Databricks, Delta Lake, or Microsoft.