---
title: "HubSpot Data Hub code formatter and linter - codefmt"
description: "free online HubSpot Data Hub code formatter and linter for custom code action javascript and python. return, callback, and def main(event) styles."
url: https://codefmt.dev/hubspot
updated: 2026-11-22
sources:
  - https://codefmt.dev/hubspot
licence: "© codefmt. Cite with attribution to https://codefmt.dev."
---

# hubspot data hub code formatter & linter

HubSpot Data Hub custom code actions support javascript (node.js 24 for new actions) and python (beta, 3.9 or 3.14; 3.9 sunsets 2027-01-05). `event` carries `inputFields`, `object`, and `origin`. return data with `return { outputFields }`, the only style node.js 24 supports; `callback({ outputFields })` works only in older node.js 20 actions. python uses `def main(event)` and returns `{ outputFields }`. runs are capped at 20 seconds and 128 MB. import JS libraries via `require` (e.g. `@hubspot/api-client`, `axios`); access secrets via `process.env`.

javascripthubspot data hub

input

```
const email=event.inputFields.email
return {outputFields:{email:email}}
```

output

click format to see the result

[format your own hubspot data hub code →](/?p=hubspot)free, no signup, formats in your browser

working inside hubspot data hub? the codefmt [Chrome and Firefox extension](/extension) adds a right-click Fix with codefmt in the code editor, so you format and lint in place without copy-pasting in and out of this page.

HubSpot's Data Hub custom code actions hang everything off an `event` object and hand back data by returning `{ outputFields }`, which is what node.js 24 accepts, while older node.js 20 actions still call `callback({ outputFields })`, which makes consistent formatting trickier than it sounds. codefmt handles both styles, keeps `event.inputFields` and `require('@hubspot/api-client')` recognized, and formats the javascript or python without changing how the action returns. when an action also carries HubL, the whole buffer goes to the HubL formatter instead of failing the parse.

## hubspot custom code globals

HubSpot Data Hub custom code actions let you run javascript or python in your workflows, with a 20 second time limit and 128 MB of memory per run. new javascript actions run node.js 24. the javascript runtime exposes `event` (trigger data with inputFields, object, and origin), `callback` (node.js 20 callback style only), `process` (for process.env secrets), and `console`. libraries like `@hubspot/api-client` and `axios` are preinstalled and loaded via `require()`.

## return and callback styles

new custom code actions run on node.js 24, which only accepts `exports.main = async (event) => {}` with a `return` of the output object. older node.js 20 actions may still use `exports.main = async (event, callback) => {}` and `callback()`, and HubSpot stopped letting you edit those after November 17, 2026. codefmt beautifies both, wrapping the code in the matching structure before formatting and stripping it back.

## linting hubspot code

codefmt runs general javascript lint rules with oxlint, not HubSpot-specific semantic checks. it doesn't check HubSpot code for undefined names, so the Data Hub runtime's globals (like `event`, `callback`, and `process`) never show up as false warnings, but a misspelled variable won't be caught either.

working on HubL templates instead of custom code actions? see the [HubL formatter and linter](/hubl), or the [HubL linter guide for HubSpot CMS](/hubspot-cms-linter).

## frequently asked questions

how do I return data from a HubSpot custom code action?

return { outputFields: { key: value } } from exports.main = async (event) => {}. node.js 24, which new actions run on, doesn't support callback-style handlers. calling callback({ outputFields }) from exports.main = async (event, callback) => {} works only in node.js 20 actions. codefmt formats both styles.

what is event.inputFields in HubSpot?

event.inputFields contains the data you configured in the workflow action settings. these are the custom properties you select when setting up the code action. you access them like event.inputFields.propertyName.

what is the difference between callback and return style in HubSpot custom code?

the return style uses exports.main = async (event) => {} and return { outputFields: {} }. it is the only style node.js 24 supports, and new actions can't use node.js 20 as of November 3, 2026\. the callback style uses exports.main = async (event, callback) => {} and callback({ outputFields: {} }); it works only in node.js 20 actions, which keep running but can't be edited after November 17, 2026\. codefmt formats both and defaults to return style.

what globals are available in HubSpot custom code actions?

HubSpot custom code action javascript exposes event (trigger data with inputFields, object, and origin), callback (only in the older callback style), process (for process.env secrets), and console. npm libraries like @hubspot/api-client, axios, and lodash are preinstalled and must be loaded via require(). they are NOT globals. codefmt knows these globals, and it doesn't check HubSpot code for undefined names, so neither the globals nor your required modules show up as false undefined warnings.

does HubSpot support python custom code actions?

yes. HubSpot custom code actions support python as well as javascript. the python entrypoint is def main(event) where event exposes inputFields via event.get('inputFields'), and you return {'outputFields': {...}}. python is in beta and offers 3.9 or 3.14; HubSpot sunsets 3.9 on January 5, 2027\. codefmt checks python 3.9 by default; if your action runs 3.14, pick it under settings, python runtime, so newer syntax such as match is not flagged. libraries like requests are preinstalled. codefmt formats HubSpot python with Ruff and wraps the code so return statements work correctly.

does codefmt catch common HubSpot custom code mistakes?

codefmt runs oxlint on your javascript, which catches general issues like unused variables and unreachable code. it doesn't check HubSpot code for undefined names, so the injected globals (event, callback, process) never show up as false warnings, but a misspelled variable won't be caught either. it does not run HubSpot-specific checks. it won't catch a missing callback call or a bad event.inputFields access, since oxlint has no knowledge of HubSpot's runtime semantics.

also format code for [zapier](/zapier), [n8n](/n8n), [pipedream](/pipedream), [make](/make), [hubspot cms (hubl)](/hubl)

other tools: [json formatter and repair tool](/json), [python formatter](/python), [snippets](/snippets)

[all platforms & comparisons →](/platforms)

primary source: [HubSpot: Workflows custom code actions](https://developers.hubspot.com/docs/api-reference/legacy/automation/workflow-actions/custom-code-actions)

## 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 and /ask report the limit in RateLimit headers, every 429 carries Retry-After, /ask puts 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
