Boolean Values in SQL INSERT Statements

How JSON true/false values are converted to SQL booleans across MySQL (TINYINT), PostgreSQL (BOOLEAN), SQLite, and SQL Server (BIT).

Data Types

Detailed Explanation

Boolean Conversion Across Dialects

JSON booleans (true and false) map to different SQL representations depending on the database dialect. The bulk INSERT tool handles these differences automatically.

Dialect Comparison

Dialect JSON true JSON false Column Type
PostgreSQL TRUE FALSE BOOLEAN
MySQL TRUE FALSE TINYINT(1)
SQLite TRUE FALSE BOOLEAN
SQL Server TRUE FALSE BIT

PostgreSQL Example

INSERT INTO "features" ("id", "name", "is_enabled", "is_beta")
VALUES
  (1, 'Dark Mode', TRUE, FALSE),
  (2, 'API v2', TRUE, TRUE),
  (3, 'Webhooks', FALSE, FALSE);

MySQL Example (with CREATE TABLE)

CREATE TABLE \`features\` (
  \`id\` INTEGER NOT NULL,
  \`name\` VARCHAR(255) NOT NULL,
  \`is_enabled\` TINYINT(1) NOT NULL,
  \`is_beta\` TINYINT(1) NOT NULL
);

INSERT INTO \`features\` (\`id\`, \`name\`, \`is_enabled\`, \`is_beta\`)
VALUES
  (1, 'Dark Mode', TRUE, FALSE),
  (2, 'API v2', TRUE, TRUE);

Edge Case: Mixed Types

If a JSON key has both boolean and integer values across different objects, the tool infers INTEGER as the column type (since booleans can be represented as 0/1). This is the conservative choice that works across all dialects.

SQL Server BIT Type

SQL Server's BIT type is semantically equivalent to a boolean but is technically a numeric type that accepts 0 and 1. The INSERT values use TRUE/FALSE which SQL Server accepts as aliases.

Use Case

You are migrating a feature flags configuration stored as JSON to a relational database and need the boolean fields correctly typed for each target database dialect.

Try It — JSON to Bulk INSERT

Open full tool