Prisma config parser?

Does the Prisma library come with some kind of parser I can use? I am in need of being able to automatically discover the generated Prisma client, and need a way of parsing and reading the config file.
1 Reply
Prisma AI Help
Prisma AI Help6mo ago
Skipping coffee for instant knowledge! Let's brew that AI answer now. Prisma does not officially expose a built-in JavaScript/TypeScript parser for its config or schema files as part of the main Prisma library. The Prisma CLI and engines handle parsing internally, and there is no documented API for programmatically parsing the Prisma schema or config directly from the official packages. The schema is written in the Prisma Schema Language (PSL), which is unique to Prisma and not based on other config formats like JSON or YAML What is the format of Prisma file (.prisma)?. However, there are community-maintained libraries that can parse Prisma schema files: - prisma-ast: Parses, modifies, and reprints Prisma schema files. - prisma-schema-parser: A TypeScript parser/formatter closely following Prisma’s PEG grammar, with helpers for attribute access and source location tracking. These libraries are not officially supported by Prisma, but are widely used in the community for tasks like schema analysis and transformation Library to parse schema.prisma. For discovering the generated Prisma Client, you can programmatically read the generator output path from your schema.prisma file (under the generator client { output = ... } block), but you’ll need to parse the file yourself or use one of the above libraries. There is no official API for this in the Prisma library itself. If you are looking to parse a Prisma config file (like prisma.config.ts), you can import and execute it as a regular TypeScript module, but again, there is no special Prisma-provided parser for this purpose Common patterns. In summary: Prisma does not ship with an official parser for config or schema files, but community tools exist for schema parsing. ✅ Great, thanks for letting us know that this solved your question!

Did you find this page helpful?