---
title: "Format Expression"
method: POST
path: "/variables/format-expression"
tags: ["variables"]
---

# Format Expression

`POST /variables/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

## Request body

- FormatExpressionRequest — Request body for formatting a PyBaMM expression with black.
  - `expression` string, required

## Response `200`

Successful Response

- FormatExpressionResponse — Response body with the black-formatted expression string.
  - `expression` string, required

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/ionworks/apis/fastapi.md) · [All operations](https://skmtc.dev/ionworks/apis/fastapi/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/ionworks/fastapi/revisions/7337a3cbdaf2/schema)
