Convert curl to ColdFusion
Convert curl commands to ColdFusion code using cfhttp. curl2code runs entirely in your browser via WebAssembly — your data stays private. For PHP, try our curl to PHP converter. For Java, see curl to Java. Below are ready-to-use ColdFusion examples.
How to copy curl from your browser
- 1
Open DevTools
Press F12 or Ctrl+Shift+I to open your browser developer tools.
- 2
Go to the Network tab
Click the Network tab and perform the action that triggers the HTTP request.
- 3
Copy as cURL
Right-click the request → Copy → Copy as cURL. Then paste it above.
Frequently Asked Questions
What is ColdFusion cfhttp?
cfhttp is ColdFusion's built-in tag and function for making HTTP requests. It supports GET, POST, PUT, DELETE, and file uploads with native integration into ColdFusion's variable scopes. No installation needed — it's part of the ColdFusion/Lucee runtime. curl2code generates cfhttp/CFML code for ColdFusion conversions.
cfhttp tag vs cfhttp function — which syntax to use?
The cfhttp tag uses CFML markup with named attributes — traditional, verbose, and readable in template files. The cfhttp() function uses CFScript with parenthesized arguments: cfhttp(url=url, method="GET") — modern and concise. Both compile to the same engine call. Use CFScript for consistency in modern ColdFusion projects. For similar syntax choices, see curl to PHP.
How to handle authentication in ColdFusion?
Add headers with cfhttpparam type="header" name="Authorization" value="Bearer #token#". For Basic auth, use username and password attributes on cfhttp directly. ColdFusion handles Base64 encoding automatically for Basic auth. curl2code converts auth flags to CFML.
How to send multipart form data in ColdFusion?
Use cfhttpparam type="file" name="upload" file="#filePath#" for file uploads. For form fields: cfhttpparam type="formfield" name="key" value="value". ColdFusion sets the multipart Content-Type and boundaries automatically. curl2code handles -F flag conversions.
How to handle HTTP errors in ColdFusion?
Wrap in try/catch: try { httpResult = cfhttp(...); } catch(any e) { ... }. Check cfhttp.statusCode for the HTTP status and cfhttp.errorDetail for error information. Non-2xx responses don't throw by default — always check the status code manually.
How to parse JSON responses in ColdFusion?
Use deserializeJSON(cfhttp.fileContent) to parse JSON into ColdFusion structs and arrays. For sending JSON: serializeJSON(data). ColdFusion's JSON functions handle complex nested structures automatically, converting between CFML data types and JSON seamlessly.
How to set timeouts in ColdFusion?
Pass the timeout parameter: cfhttp(url=url, timeout=30). The value is in seconds. There's no built-in retry — implement with a loop and try/catch. Default timeout varies by ColdFusion/Lucee version.
How to use a proxy in ColdFusion?
Pass proxy parameters: cfhttp(url=url, proxyServer="proxy.host", proxyPort=8080). For proxy auth, add proxyUser and proxyPassword parameters. curl2code converts -x flags to CFML proxy settings.
How to send a POST request with JSON body in ColdFusion?
Convert a curl POST command like curl -X POST -H "Content-Type: application/json" -d '{"key":"value"}' URL to ColdFusion using curl2code. The generated code uses cfhttpparam type='body' value='#serializeJSON(data)#'. curl2code automatically detects -d/--data flags with JSON content and sets the appropriate Content-Type header in the cfhttp code.
How to add Bearer token authorization in ColdFusion?
Pass curl -H "Authorization: Bearer YOUR_TOKEN" URL to curl2code and it generates cfhttp code with the auth header: cfhttpparam type='header' name='Authorization' value='Bearer TOKEN'. curl2code detects Bearer tokens from both -H "Authorization: Bearer ..." and --oauth2-bearer flags. For Basic auth, use -u user:pass.
How to set Content-Type header in ColdFusion?
curl2code converts curl -H "Content-Type: application/json" URL to cfhttp code with the proper header: cfhttpparam type='header' name='Content-Type' value='application/json'. For -d data, curl defaults to application/x-www-form-urlencoded; for -F form uploads, it uses multipart/form-data. curl2code maps each to the correct cfhttp API.