cURL to Code Converter
cURLコマンドをJavaScript, Python, PHP, Goのコードに変換。APIテストの効率化に。
// ここに結果が表示されます
cURL to Code Converterの使い方
cURLコマンドを貼り付けて変換ボタンを押すと、JavaScript (fetch)、Python (requests)、 PHP (curl)、Go (net/http) のコードに変換されます。ヘッダー、リクエストボディ、 HTTPメソッドを自動的に検出して、各言語のイディオムに合ったコードを生成します。 APIドキュメントのcURL例をアプリケーションコードに変換する際に便利です。
How to Use the cURL to Code Converter
This tool converts cURL commands to working code in JavaScript (fetch API), Python (requests), PHP (curl), and Go (net/http). It automatically parses headers, request body, HTTP method, and URL from the cURL command. Perfect for converting API documentation examples into your application code. Supports multi-line cURL commands with backslash line continuations. All processing is done locally.
よくあるエラーと対処 / Common Errors and Fixes
| エラー / Error | 原因 / Cause | 対処 / Fix |
|---|---|---|
| -d と --data-urlencode の混同 -d vs --data-urlencode | -d は生のまま送信。スペースや日本語を含む値はエンコードされない -d sends raw bytes without encoding | 値にスペース・記号がある場合は --data-urlencode を使う Use --data-urlencode for unescaped values |
| シェルの引用符でJSONが壊れる Shell quoting breaks JSON bodies | ダブルクォート内の " や $ がシェルに解釈される Inner quotes and $ expand inside double quotes | ボディ全体をシングルクォートで囲む(Windowsのcmdでは逆に二重引用符+エスケープ) Wrap the body in single quotes on POSIX shells |
| -u の認証情報が変換されない -u credentials not carried over | -u user:pass は Authorization: Basic ヘッダの糖衣構文 -u is sugar for a Basic auth header | 変換後コードでは Authorization ヘッダ(Base64)として明示する Express it as an explicit Authorization header |
| GETなのにボディが付く GET with a body | -d を付けるとcurlは自動でPOSTになるが、-X GET を併用すると矛盾する -d implies POST; forcing -X GET conflicts | -X の手動指定は基本不要。メソッドは -d / -F の有無に任せる Drop manual -X; let curl infer the method |
| マルチパート(-F)が再現できない Multipart (-F) not reproduced | ファイルアップロードは各言語で FormData / multipart 構築が必要 File uploads need language-specific multipart handling | fetch は FormData、requests は files= 引数で書き換える Use FormData (JS) or files= (Python) |
変換例 / Before & After
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-H "Authorization: Bearer TOKEN" \
-d '{"name": "Taro"}'
↓ JavaScript (fetch)
const res = await fetch("https://api.example.com/users", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer TOKEN",
},
body: JSON.stringify({ name: "Taro" }),
});Why browser-only?
A cURL command frequently contains everything an attacker would want: bearer tokens, API keys, cookies, and internal endpoints. Pasting it into a server-backed converter hands all of that to a third party. This converter parses and generates code entirely in your browser — credentials in your command never leave your machine. Verify in the DevTools Network tab: zero requests.
cURLコマンドにはトークンやAPIキーがそのまま含まれます。本ツールは解析・変換の全てが ブラウザ内で完結し、認証情報が外部送信されることはありません。
関連ツール / Related Tools
開発をもっと効率的に
PR
レンタルサーバー
エックスサーバー
国内シェアNo.1の高速レンタルサーバー(エックスサーバー社調べ)。WordPressも簡単セットアップ。
詳しく見る →レンタルサーバー
ConoHa WING
国内最速クラスのレンタルサーバー。独自ドメイン永久無料特典付き(特典内容は変更される場合があります)。
詳しく見る →レンタルサーバー
mixhost
高速SSD・HTTP/3対応のクラウド型レンタルサーバー。
詳しく見る →VPS
シンVPS
メモリ単価国内最安・オールNVMe SSD搭載の高性能VPS。開発・検証環境の構築に。
詳しく見る →Windows VPS
ConoHa for Windows Server
Windows環境のVPS。リモートデスクトップで開発・検証環境を構築。
詳しく見る →