Blog

Convert identifier case using an API response code

Convert the same phrase to camelCase, snake_case, and other styles with Case Style Transformer. Follow the screenshots to adjust acronym capitalization and copy the result you need.

The English tool shows six case styles generated from api response code.
Conversion results in English. Copy the style you need from its card.

Suppose you read JSON returned by an API and store its response code in a JavaScript variable. In this example, the JSON key separates words with underscores, while the variable name capitalizes the first letter of each word starting with the second. The same concept therefore appears as api_response_code in the response and apiResponseCode in the variable. Enter the phrase once in Case Style Transformer to see six styles side by side. The conversion happens in your browser.

Enter a phrase and compare the results

  1. Enter api response code in “Enter the text or identifiers to convert”.
  2. Check that “3 words” appears below the input. The results update as you type.
  3. Choose the result that fits the convention where it will be used, such as apiResponseCode for the variable or api_response_code for the JSON key.
The English input contains api response code and the counter reads 3 words.
Use the word count to check that the phrase was split as expected.

Adjust acronym capitalization and copy the result

Acronyms can take a little thought. Even within PascalCase, check the surrounding code to decide whether to start with API or Api.

  1. Replace the input with API response code. Check that the PascalCase result is APIResponseCode.
  2. Turn off “Keep all-uppercase words” and check that PascalCase becomes ApiResponseCode.
  3. Click “Copy” on the PascalCase card and paste the result where you need it in your editor. Save the file from the editor if you want to keep it.
The English interface shows ApiResponseCode selected and confirms that PascalCase was copied.
Choose a style by copying from its card. The confirmation appears at the bottom of the tool.

When the word count differs from what you expected

For example, status200 has no spaces. The default settings still split it where letters meet digits, so the snake_case result is status_200. Turn off “Split between letters and digits” to keep the number as part of the same word. To join words separated by spaces, remove those spaces from the input as well.

Before pasting a result into code, check for reserved words, leading digits, and conflicts with existing names. The tool suggests spellings. Whether a suggestion is a valid identifier depends on your project’s language and rules.