Registry / devops / axios-case-converter

axios-case-converter

JSON →
library1.1.1jsnpmunverified

Axios middleware that automatically transforms object keys between snake_case and camelCase in HTTP requests and responses. Current stable version is 1.1.1. It uses Axios interceptors to convert outgoing request data, params, and headers to snake_case/Header-Case, and incoming response data and headers back to camelCase. Built on top of the 'change-case' library. Requires Axios >=1.0.0 as a peer dependency. Differentiates from similar libraries by also handling URL params and headers, and offering fine-grained options like preservedKeys, ignoreHeaders, and caseFunctions for overriding transformation behavior. Ships TypeScript declarations.

npm install axios-case-converter
INSTALL
IMPORT
SIG · AXIOS-CASE-CONVERT
A
axios-case-converter
devopsjavascriptv1.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

applyCaseMiddleware
import applyCaseMiddleware from 'axios-case-converter'
const applyCaseMiddleware = require('axios-case-converter')
Package ships both ESM and CJS; default export only. Use named import only if using TypeScript with esModuleInterop.
applyCaseMiddleware (default)
import applyCaseMiddleware from 'axios-case-converter'
import { applyCaseMiddleware } from 'axios-case-converter'
The function is a default export, not a named export. Named import will result in undefined.
TypeScript types
import type { Options } from 'axios-case-converter'
import { Options } from 'axios-case-converter'
Options type is exported as an interface; use type import to avoid runtime inclusion.

Creates an Axios instance with automatic camelCase/snake_case conversion for requests and responses.

import applyCaseMiddleware from 'axios-case-converter'; import axios from 'axios'; // Create axios instance with case conversion const client = applyCaseMiddleware(axios.create({ baseURL: 'https://api.example.com' })); async function fetchData() { try { const { data } = await client.post('/users', { fullName: 'John Doe', emailAddress: 'john@example.com' }); // outgoing: { full_name: 'John Doe', email_address: 'john@example.com' } // incoming response keys become camelCase console.log(data); } catch (error) { console.error(error); } } fetchData();
Debug
Known issues
breakingVersion 1.x requires Axios >=1.0.0; version 0.x required Axios <=0.27.x.
fix
Upgrade axios to version >=1.0.0 and <2.0.0.
affects: >=1.0.0
deprecatedInternet Explorer polyfills for Object.entries and FormData.entries may not be needed in modern environments.
fix
Polyfill only if targeting IE. For modern browsers, no action needed.
affects: >=0.0.0
gotchaFunction passed to preservedKeys receives the snake_case key, not the camelCase key.
fix
Check against snake_case strings when using preservedKeys as a function.
affects: >=0.0.0
gotchaHeaders are converted to Header-Case (e.g., user-agent -> User-Agent) but incoming headers are converted back to camelCase. This may conflict with custom headers.
fix
Set ignoreHeaders: true if you need to preserve header casing.
affects: >=0.0.0
deprecatedThe caseOptions.stripRegexp default includes '[]' characters; this is non-standard and may cause unexpected transformations.
fix
Override caseOptions.stripRegexp to match standard change-case behavior if needed.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: applyCaseMiddleware is not a function
Named import instead of default import
fix
Use: import applyCaseMiddleware from 'axios-case-converter'
Error: Cannot find module 'axios'
Axios is a peer dependency and not installed.
fix
Run: npm install axios
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
axiosrequiredpeer dependency; the library wraps an Axios instance
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
axios-case-converter — npm install axios-case-converter · libregistry