> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ionworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Format Expression

> Format a PyBaMM expression string using black.

Wraps the expression in a dummy assignment, runs black, then
strips the assignment back off so the caller gets just the
formatted expression.

Parameters
----------
request : FormatExpressionRequest
    expression: Raw PyBaMM expression string

Returns
-------
FormatExpressionResponse
    expression: Black-formatted expression string



## OpenAPI

````yaml https://api.ionworks.com/openapi.json post /variables/format-expression
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.ionworks.com
    description: Production
security: []
paths:
  /variables/format-expression:
    post:
      tags:
        - variables
      summary: Format Expression
      description: |-
        Format a PyBaMM expression string using black.

        Wraps the expression in a dummy assignment, runs black, then
        strips the assignment back off so the caller gets just the
        formatted expression.

        Parameters
        ----------
        request : FormatExpressionRequest
            expression: Raw PyBaMM expression string

        Returns
        -------
        FormatExpressionResponse
            expression: Black-formatted expression string
      operationId: format_expression_variables_format_expression_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FormatExpressionRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FormatExpressionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    FormatExpressionRequest:
      properties:
        expression:
          type: string
          title: Expression
      type: object
      required:
        - expression
      title: FormatExpressionRequest
      description: Request body for formatting a PyBaMM expression with black.
    FormatExpressionResponse:
      properties:
        expression:
          type: string
          title: Expression
      type: object
      required:
        - expression
      title: FormatExpressionResponse
      description: Response body with the black-formatted expression string.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````