zapier code formatter

zapier code actions run inside an async function with access to inputData, z (zapier object), and lodash.

zapier code actions let you write custom javascript to transform data, make API requests, and connect services. your code runs inside an async function with access to inputData, z (the zapier object), fetch, and _ (lodash).

standard formatters and linters fail on zapier code because it uses top-level await and bare return statements. codefmt wraps your code in the correct async function before formatting, then strips it back — so you get clean, formatted code that works directly in zapier.

codefmt also includes a zapier-specific lint plugin that understands z.request vs fetch patterns and catches common mistakes before you publish your zap. the formatter handles both simple code actions and full platform integration code.

frequently asked questions

why does prettier fail on my zapier code?

zapier code runs inside an invisible async function wrapper. this means top-level await and bare return statements are valid inside zapier, but invalid as standalone javascript. prettier tries to parse your code as a complete program and fails. codefmt handles this automatically by wrapping your code before formatting and stripping the wrapper afterward.

what globals are available in zapier code actions?

zapier injects inputData (your trigger/action input), z (zapier platform object with z.request, z.console, z.JSON), fetch (node fetch), console, and _ (lodash). codefmt knows about all of these and won't flag them as undefined.

can i use async/await in zapier code?

yes. zapier wraps your code in an async function, so top-level await works directly. you can also use return to send data to the next step. codefmt preserves your async/await patterns during formatting.

should i use z.request or fetch in zapier code actions?

z.request is the recommended way to make HTTP requests in zapier. it automatically handles authentication, retries, and error responses from connected apps. fetch works too, but you lose zapier's built-in auth and error handling. codefmt recognizes both z.request and fetch as valid globals.

does codefmt support zapier platform variant formatting?

yes. codefmt supports zapier's platform-specific code patterns including code actions and custom integrations. the zapier lint plugin catches common mistakes like missing return statements and flags incorrect use of zapier globals, giving you instant feedback before you deploy your zap.