API 문서, Postman, 또는 브라우저 DevTools 네트워크 탭에서 curl 명령을 복사했습니다. 이제 그 요청을 애플리케이션에서 실행해야 합니다. curl 플래그를 라이브러리 호출로 직접 번역하는 것은 번거롭고 오류가 생기기 쉽습니다——특히 헤더, 인증 토큰, 폼 데이터, 쿠키가 있을 때는 더욱 그렇습니다. cURL to code 변환기가 이를 즉시 처리합니다.

cURL to code 기능

도구가 curl 명령을 파싱하여 선택한 언어로 동등한 코드를 출력합니다:

  • Pythonrequests 또는 httpx
  • JavaScriptfetch 또는 axios
  • Node.jsnode-fetch 또는 네이티브 https 모듈
  • Gonet/http
  • PHPcurl 확장 또는 GuzzleHttp
  • Rubynet/http 또는 Faraday
  • JavaHttpClient 또는 OkHttp

curl 명령을 붙여 넣고 언어를 선택하면 동작하는 코드가 나옵니다.

주요 curl 플래그와 매핑

플래그와 라이브러리의 매핑 관계를 이해하면 출력을 커스터마이징할 때 도움이 됩니다.

-X / --request — HTTP 메서드

curl -X POST https://api.example.com/users
import requests
response = requests.post('https://api.example.com/users')
fetch('https://api.example.com/users', { method: 'POST' })

-H / --header — 요청 헤더

curl -H "Content-Type: application/json" \
     -H "Authorization: Bearer eyJhbGci..." \
     https://api.example.com/users
import requests
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer eyJhbGci...'
}
response = requests.get('https://api.example.com/users', headers=headers)
fetch('https://api.example.com/users', {
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer eyJhbGci...'
  }
})

-d / --data — 요청 본문

curl -X POST https://api.example.com/users \
     -H "Content-Type: application/json" \
     -d '{"name": "Alice", "email": "[email protected]"}'
import requests, json
data = {"name": "Alice", "email": "[email protected]"}
response = requests.post(
    'https://api.example.com/users',
    headers={'Content-Type': 'application/json'},
    json=data
)
package main

import (
    "bytes"
    "encoding/json"
    "net/http"
)

func main() {
    data := map[string]string{"name": "Alice", "email": "[email protected]"}
    body, _ := json.Marshal(data)
    req, _ := http.NewRequest("POST", "https://api.example.com/users", bytes.NewBuffer(body))
    req.Header.Set("Content-Type", "application/json")
    client := &http.Client{}
    client.Do(req)
}

-F / --form — 멀티파트 폼 데이터

curl -F "file=@/path/to/report.pdf" \
     -F "title=Q1 Report" \
     https://api.example.com/upload
import requests
with open('/path/to/report.pdf', 'rb') as f:
    files = {'file': f}
    data = {'title': 'Q1 Report'}
    response = requests.post('https://api.example.com/upload', files=files, data=data)

-u / --user — HTTP Basic 인증

curl -u username:password https://api.example.com/protected
import requests
response = requests.get(
    'https://api.example.com/protected',
    auth=('username', 'password')
)

-k / --insecure — TLS 검증 건너뛰기

curl -k https://localhost:8443/api/health
import requests
response = requests.get('https://localhost:8443/api/health', verify=False)

주의: verify=False / InsecureSkipVerify: true는 개발 환경과 내부 도구에서만 사용하고 프로덕션에서는 절대 사용하지 마세요.

실제 워크플로: 브라우저 DevTools에서 코드로

가장 흔한 사용 사례는 브라우저 DevTools에서 요청을 가져오는 것입니다.

  1. Chrome/Firefox DevTools 열기 → 네트워크
  2. 복제할 요청 찾기
  3. 마우스 우클릭 → 복사cURL로 복사
  4. 변환기에 붙여 넣기
  5. 타겟 언어 선택

이 워크플로는 특히 다음에 유용합니다:

  • 내부 API 리버스 엔지니어링
  • 자동화 테스트에서 브라우저 동작 재현
  • 공식 SDK가 없는 서드파티 서비스 연동 구축

API 문서의 curl 명령

대부분의 API 문서에는 curl 예제가 포함되어 있습니다. 문서와 에디터를 동시에 보면서 직접 번역하는 것 대신 변환기를 활용하세요.

Stripe API 예시:

curl https://api.stripe.com/v1/charges \
  -u sk_test_YOUR_STRIPE_TEST_KEY: \
  -d amount=2000 \
  -d currency=usd \
  -d source=tok_visa \
  -d description="Charge for [email protected]"
import stripe
stripe.api_key = 'sk_test_YOUR_STRIPE_TEST_KEY'

charge = stripe.Charge.create(
    amount=2000,
    currency='usd',
    source='tok_visa',
    description='Charge for [email protected]'
)

간단한 케이스에서는 변환기 출력을 그대로 사용할 수 있습니다. 프로덕션 코드에는 재시도, 페이지네이션, 오류 처리를 담당하는 공식 SDK가 있다면 그것을 사용하세요.

복잡한 curl 명령 처리

여러 -d 플래그

curl은 여러 -d 플래그를 URL 인코딩된 문자열로 병합합니다. 변환기가 이를 올바르게 처리합니다:

curl -X POST https://api.example.com/form \
     -d "field1=value1" \
     -d "field2=value2"

field1=value1&field2=value2가 본문이 됩니다.

리다이렉트 따라가기 (-L)

curl -L https://short.url/abc123
# requests는 기본적으로 리다이렉트를 따라감
response = requests.get('https://short.url/abc123', allow_redirects=True)

도구 사용해보기

curl을 코드로 즉시 변환 →

어떤 curl 명령이든 붙여 넣고 Python, JavaScript, Go, PHP 등 타겟 언어를 선택하면 몇 초 만에 동작하는 코드가 나옵니다. 사용 사례:

  • API 문서 예제를 내 언어로 변환
  • 셸 스크립트를 애플리케이션 코드로 이전
  • 다른 언어를 선호하는 팀원과 API 호출 예제 공유
  • curl 출력과 라이브러리 동작을 비교해 HTTP 요청 디버깅

변환은 모두 브라우저 내에서 실행됩니다——서버 없음, 로깅 없음.