# NestExpressBodyParserType

**Kind:** Type

**Source:** [`packages/platform-express/interfaces/nest-express-body-parser.interface.ts`](https://github.com/nestjs/nest/blob/master/packages/platform-express/interfaces/nest-express-body-parser.interface.ts#L4)

**Part of:** [Platform Express](subsystem-packages-platform-express)

Interface defining possible body parser types, to be used with `NestExpressApplication.useBodyParser()`.

`NestExpressBodyParserType` defines the supported body parser names accepted by `NestExpressApplication.useBodyParser()`. It lets Express-based Nest applications configure how incoming request bodies are parsed, including JSON, URL-encoded form data, raw buffers, and plain text.

## Definition

```ts
'json' | 'urlencoded' | 'text' | 'raw'
```

## Diagram

```mermaid
graph LR
  A[Incoming HTTP Request] --> B[NestExpressApplication.useBodyParser]
  B --> C{NestExpressBodyParserType}
  C --> D[json]
  C --> E[urlencoded]
  C --> F[raw]
  C --> G[text]
  D --> H[Parsed request body]
  E --> H
  F --> H
  G --> H
```

## Usage

```ts
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import type { NestExpressApplication } from '@nestjs/platform-express';

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);

  const parserType: 'json' = 'json';

  app.useBodyParser(parserType, {
    limit: '10mb',
  });

  await app.listen(3000);
}

bootstrap();
```

## AI Coding Instructions

- Use this type only with `NestExpressApplication.useBodyParser()` in applications running on the Express platform.
- Choose `json` for JSON APIs, `urlencoded` for HTML form submissions, `raw` for buffer-based payloads such as webhook signatures, and `text` for plain-text requests.
- Configure parsers before starting the application with `app.listen()` so request handling uses the intended parser configuration.
- Avoid registering conflicting body parsers for the same content type, especially when validating raw webhook payload signatures.
- Keep parser options compatible with Express/body-parser options, such as `limit`, `type`, and `extended` for URL-encoded payloads.
