---
title: "how to format javascript and python in a zapier code step"
url: https://codefmt.dev/blog/format-javascript-python-zapier-code-step
updated: 2026-10-05
sources:
  - https://codefmt.dev/blog/format-javascript-python-zapier-code-step
licence: "© codefmt. Cite with attribution to https://codefmt.dev."
---

# how to format javascript and python in a zapier code step

by [josh ozuna](/about) · codefmt

published June 2, 2026 · updated October 5, 2026

to format javascript or python in a [Code by Zapier](/zapier) step, paste your code into codefmt. it wraps the code in Zapier's async runtime before formatting, so top-level `await` and bare `return` never trigger a parse error, then hands back clean, linted code you can drop straight back into the step.

## why Prettier errors on Code by Zapier snippets

Code by Zapier runs your javascript inside an invisible async function. that wrapper is why `await` works at the top level of your step and why a bare `return` can hand data to the next action. but it also means your code is not a complete, standalone program.

Prettier and most editor formatters parse javascript as a whole program. they hit that top-level `await` or `return`, decide the syntax is invalid, and refuse to format. codefmt avoids this by wrapping your code in the same async function Zapier uses, formatting the wrapped result with biome, then stripping the wrapper back off. it also detects Zapier's newer sdk-in-code form (a top-level `import` with `export default async function main(...)`) and parses that at module scope, so it formats cleanly too. the [zapier code formatter](/zapier) page is the canonical explanation of the runtime and how codefmt handles it.

## how to format a zapier code step

1. copy the code out of your Code by Zapier step.
2. paste it into the [codefmt Zapier formatter](/zapier) and choose javascript or python.
3. codefmt wraps the code in Zapier's runtime, formats it (biome for javascript, ruff for python), lints it (oxlint for javascript, ruff for python), and strips the wrapper.
4. copy the formatted result back into your Code step.
5. or install the [Chrome or Firefox extension](/extension) and run “Fix with codefmt” from the right-click menu without leaving the Zapier editor.

## codefmt vs the alternatives

| tool                | built for                                                          | formats code source | handles zapier's async wrapper                   | lints               |
| ------------------- | ------------------------------------------------------------------ | ------------------- | ------------------------------------------------ | ------------------- |
| codefmt             | code written inside automation platforms                           | yes (biome / ruff)  | yes, wraps and strips automatically              | yes (oxlint / ruff) |
| Formatter by Zapier | transforming field values (dates, numbers, text) in a no-code step | no, a different job | not applicable                                   | no                  |
| Prettier            | formatting standalone javascript projects                          | yes                 | no, parse error on top-level await / bare return | no, format only     |

see the side-by-side breakdowns: [codefmt vs Formatter by Zapier](/vs-built-in-zapier-formatter) and [codefmt vs the Prettier playground](/vs-prettier-playground).

## the zapier globals codefmt knows

Zapier injects runtime globals into your step. a generic linter flags them as undefined; codefmt registers them so the false positives go away and real issues still surface.

| language    | global                                          | what it is               |
| ----------- | ----------------------------------------------- | ------------------------ |
| javascript  | inputData                                       | your mapped input fields |
| output      | the result you assign to return data            |                          |
| fetch       | preinstalled, no require needed                 |                          |
| callback    | classic async completion, callback(err, output) |                          |
| console     | logging visible in the Zapier task history      |                          |
| python      | input\_data                                     | your mapped input fields |
| output      | the result dict you assign                      |                          |
| StoreClient | Zapier's key-value store, StoreClient('secret') |                          |
| requests    | preinstalled http library                       |                          |

for python-heavy workflows, the dedicated [python formatter](/python) page covers ruff formatting and lint rules in more depth.

[format your Zapier code →](/zapier) paste a Code by Zapier step and get clean, linted javascript or python back in one pass.

## frequently asked questions

what code formatter works with a Zapier code step?

use codefmt. it wraps your code in Zapier's async runtime before formatting, so top-level await and bare return don't trigger the parse errors that stop Prettier. it formats javascript with biome and python with ruff, lints both, and runs free in your browser with no account.

why does Prettier fail on my Zapier code?

Code by Zapier runs your javascript inside an invisible async function, so top-level await and bare return are valid there but invalid as a standalone program. Prettier parses your code as a complete program and errors out. codefmt wraps the code first, formats it, then strips the wrapper back off.

does Zapier have a built-in code formatter?

Formatter by Zapier is a no-code step for transforming field values like dates, numbers, and text. it is built for a different job and does not pretty-print the source of a Code by Zapier step. for that you paste your code into codefmt or use the codefmt browser extension.

can I format Zapier python code as well as javascript?

yes. codefmt formats and lints Zapier python with ruff (black-compatible formatting plus 500+ lint rules) and recognizes Zapier's python globals input\_data, output, StoreClient, and requests, so they are not flagged as undefined.

is codefmt free, and does it send my code anywhere?

codefmt is free, with no account or sign-in. formatting runs client-side via WebAssembly, so formatting never sends your code anywhere. javascript lint diagnostics are the one server-assisted step: processed in memory, never stored, never logged. the Chrome and Firefox extension formats inside the Zapier editor by sending that one snippet to codefmt.dev/api/format over HTTPS, processed in memory and never stored.

primary source: [Zapier: Use JavaScript code in Zaps](https://help.zapier.com/hc/en-us/articles/8496310939021-Use-JavaScript-code-in-Zaps)

## for agents (added to every page twin, not part of the page)

- format API: POST https://codefmt.dev/api/format (OpenAPI: https://codefmt.dev/api/openapi.json, code up to 51,200 characters, 50KB of ASCII (400 above it), request body up to 100KB, counted in bytes (413 above it), no authentication)
- MCP server: POST https://codefmt.dev/api/mcp (tools: format_code, format_json, ask_codefmt; manifest: https://codefmt.dev/.well-known/mcp.json)
- rate limit: 60 requests per minute per ip across format api calls, mcp and a2a tool calls, and /ask (mcp handshakes and listings are not counted). the count is kept per server instance, so treat it as a ceiling to stay under rather than an exact budget. the format api reports where you stand in RateLimit headers and its 429 carries Retry-After; /ask answers a 429 with the message in answer, and an mcp tool call over the limit returns a tool result saying to try again in a minute
- auth statement: https://codefmt.dev/auth.md (no accounts, api keys or oauth; send no authorization header)
- site index for agents: https://codefmt.dev/llms.txt
- full reference (request bodies for every language, a copy-paste curl command, platform globals, troubleshooting): https://codefmt.dev/llms-full.txt
