Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Prisma · Command

prisma format

prisma format validates and reformats a Prisma schema, saving the result. Use --schema or --config when the schema or Prisma configuration is stored at a custom path.

How it works

Run this Prisma CLI command to validate and reformat a schema file, then persist the formatted result. By default, Prisma uses the project’s default schema; use --schema to select another file, and --config to select a custom Prisma configuration.

Syntax

prisma format [options]

Parameters

NameTypeDescription
-h, --helpflagDisplays command help.
--configoptionSpecifies a custom Prisma configuration file path.
--schemaoptionSpecifies a custom Prisma schema path.

Returns

Formats and persists the schema; formatting fails when schema validation errors are present.

Key points

  • The command reformats a Prisma schema file into Prisma’s consistent layout.
  • Its operation combines validation, formatting, and writing the result back to the schema.
  • Invoke the command with optional flags using this CLI form.
  • Use --config when the Prisma configuration is not in its default location.
  • Use --schema to format a schema located at a custom path.

Common mistakes

  • Formatting does not complete when the schema contains validation errors; fix those errors first.

Example: Format a specific schema

npx prisma format --schema=./prisma/schema.prisma

Formats and validates the specified Prisma schema file in place.

When to use it

Clean up a schema

Run it after editing a schema to normalize its structure and catch validation problems.

Target an alternate schema

Format a schema outside the project default location.

Select custom configuration

Use a non-default Prisma configuration file.

Interview questions

QWhat does prisma format do?

It validates the schema, formats it consistently, and saves the formatted schema. Running it without a path targets the default schema.

Follow-up: How would you target a non-default schema? Use --schema followed by its relative or absolute path.

QHow do you format a schema in a different location?

The command syntax is prisma format [options]. The documented options include --schema for a custom schema path and --config for a custom Prisma config path.

Follow-up: What option displays command help? Use -h or --help.

QWhat happens when the schema contains validation errors?

A validation failure prevents formatting from succeeding. The schema must therefore be valid before Prisma can persist the formatted result.

Follow-up: How could a project format schemas automatically while editing? Prisma documentation also describes formatting through the Prisma VS Code extension.

  • Prisma schema
  • Prisma VS Code extension
  • prisma validate

Source: Format & Validate Prisma Schema. Checked 2026-10-16.