JSON을 Excel로 변환: 완벽한 가이드 2026
JSON 데이터를 Excel 스프레드시트로 변환하는 방법을 배우세요. 온라인 도구, Python, JavaScript 및 자동화 방법을 다루는 종합 가이드입니다.
Big JSON Team
• Technical WriterExpert in JSON data manipulation, API development, and web technologies. Passionate about creating tools that make developers' lives easier.
# JSON을 Excel로 변환: 완벽한 가이드 2026
JSON 데이터를 Excel 스프레드시트로 변환하는 것은 일반적인 작업입니다. 이 가이드는 온라인 도구, 프로그래밍 방법 및 자동화 기술을 포함한 모든 방법을 다룹니다.
온라인 JSON to Excel 변환기
1. ConvertCSV.com
기능:- JSON → Excel (XLSX)
- JSON → CSV
- 대용량 파일 지원
- 무료 사용
2. JSON-to-Excel
URL: json-to-excel.com 특징:- 드래그 앤 드롭
- 대용량 파일
- 사용자 정의 포맷팅
- 즉시 다운로드
3. Code Beautify
URL: codebeautify.org/json-to-excel-converter 장점:- 간단한 인터페이스
- 빠른 변환
- 미리보기 옵션
Python으로 변환
pandas 사용
import pandas as pd
import json
# JSON 파일 읽기
with open('data.json', 'r', encoding='utf-8') as f:
data = json.load(f)
# DataFrame으로 변환
df = pd.DataFrame(data)
# Excel로 저장
df.to_excel('output.xlsx', index=False, engine='openpyxl')
print("변환 완료!")
중첩된 JSON 처리
import pandas as pd
import json
# 중첩된 JSON
json_data = '''
[
{
"name": "홍길동",
"age": 30,
"address": {
"city": "서울",
"zipCode": "12345"
},
"skills": ["Python", "JavaScript"]
},
{
"name": "김철수",
"age": 25,
"address": {
"city": "부산",
"zipCode": "67890"
},
"skills": ["Java", "C++"]
}
]
'''
data = json.loads(json_data)
# 중첩 구조 평탄화
df = pd.json_normalize(data)
# Excel로 저장
df.to_excel('users.xlsx', index=False)
결과 Excel:
| name | age | address.city | address.zipCode | skills |
|------|-----|--------------|-----------------|--------|
| 홍길동 | 30 | 서울 | 12345 | [Python, JavaScript] |
| 김철수 | 25 | 부산 | 67890 | [Java, C++] |
여러 시트로 저장
import pandas as pd
import json
# 여러 데이터셋
data = {
"users": [
{"name": "홍길동", "age": 30},
{"name": "김철수", "age": 25}
],
"products": [
{"id": 1, "name": "노트북", "price": 1000000},
{"id": 2, "name": "마우스", "price": 20000}
]
}
# Excel 작성기
with pd.ExcelWriter('output.xlsx', engine='openpyxl') as writer:
for sheet_name, items in data.items():
df = pd.DataFrame(items)
df.to_excel(writer, sheet_name=sheet_name, index=False)
print("여러 시트 생성 완료!")
스타일링
import pandas as pd
from openpyxl import load_workbook
from openpyxl.styles import Font, PatternFill, Alignment
# 데이터 생성
df = pd.DataFrame([
{"이름": "홍길동", "나이": 30, "도시": "서울"},
{"이름": "김철수", "나이": 25, "도시": "부산"}
])
# Excel로 저장
filename = 'styled.xlsx'
df.to_excel(filename, index=False)
# 스타일 적용
wb = load_workbook(filename)
ws = wb.active
# 헤더 스타일
header_fill = PatternFill(start_color="4472C4", end_color="4472C4", fill_type="solid")
header_font = Font(bold=True, color="FFFFFF")
for cell in ws[1]:
cell.fill = header_fill
cell.font = header_font
cell.alignment = Alignment(horizontal='center')
# 열 너비 조정
for column in ws.columns:
max_length = 0
column_letter = column[0].column_letter
for cell in column:
try:
if len(str(cell.value)) > max_length:
max_length = len(cell.value)
except:
pass
adjusted_width = (max_length + 2)
ws.column_dimensions[column_letter].width = adjusted_width
wb.save(filename)
print("스타일 적용 완료!")
JavaScript/Node.js로 변환
xlsx 라이브러리 사용
const XLSX = require('xlsx');
const fs = require('fs');
// JSON 파일 읽기
const jsonData = JSON.parse(fs.readFileSync('data.json', 'utf8'));
// 워크시트 생성
const ws = XLSX.utils.json_to_sheet(jsonData);
// 워크북 생성
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
// Excel 파일 저장
XLSX.writeFile(wb, 'output.xlsx');
console.log('변환 완료!');
설치:
npm install xlsx
여러 시트
const XLSX = require('xlsx');
const data = {
users: [
{ name: "홍길동", age: 30 },
{ name: "김철수", age: 25 }
],
products: [
{ id: 1, name: "노트북", price: 1000000 },
{ id: 2, name: "마우스", price: 20000 }
]
};
// 워크북 생성
const wb = XLSX.utils.book_new();
// 각 데이터셋을 시트로 추가
Object.keys(data).forEach(sheetName => {
const ws = XLSX.utils.json_to_sheet(data[sheetName]);
XLSX.utils.book_append_sheet(wb, ws, sheetName);
});
// 저장
XLSX.writeFile(wb, 'output.xlsx');
브라우저에서 변환
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
</head>
<body>
<button onclick="convertToExcel()">Excel로 다운로드</button>
<script>
function convertToExcel() {
const jsonData = [
{ 이름: "홍길동", 나이: 30, 도시: "서울" },
{ 이름: "김철수", 나이: 25, 도시: "부산" }
];
const ws = XLSX.utils.json_to_sheet(jsonData);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "데이터");
XLSX.writeFile(wb, 'data.xlsx');
}
</script>
</body>
</html>
고급 변환
복잡한 JSON 구조
import pandas as pd
import json
# 복잡한 중첩 JSON
json_data = '''
{
"company": "테크 이노베이션",
"departments": [
{
"name": "개발팀",
"employees": [
{"name": "홍길동", "role": "시니어 개발자", "salary": 80000000},
{"name": "김철수", "role": "주니어 개발자", "salary": 50000000}
]
},
{
"name": "디자인팀",
"employees": [
{"name": "이영희", "role": "수석 디자이너", "salary": 70000000}
]
}
]
}
'''
data = json.loads(json_data)
# 부서별 직원 데이터 추출
all_employees = []
for dept in data['departments']:
for emp in dept['employees']:
emp['department'] = dept['name']
emp['company'] = data['company']
all_employees.append(emp)
df = pd.DataFrame(all_employees)
df.to_excel('employees.xlsx', index=False)
데이터 필터링 및 변환
import pandas as pd
import json
# JSON 로드
with open('data.json', 'r', encoding='utf-8') as f:
data = json.load(f)
df = pd.DataFrame(data)
# 필터링
df_filtered = df[df['age'] > 25]
# 열 선택
df_selected = df[['name', 'age', 'email']]
# 정렬
df_sorted = df.sort_values('age', ascending=False)
# 그룹화
df_grouped = df.groupby('city').agg({
'age': 'mean',
'name': 'count'
}).rename(columns={'name': 'count'})
# 각각을 다른 시트로 저장
with pd.ExcelWriter('analysis.xlsx') as writer:
df.to_excel(writer, sheet_name='전체', index=False)
df_filtered.to_excel(writer, sheet_name='필터링', index=False)
df_sorted.to_excel(writer, sheet_name='정렬', index=False)
df_grouped.to_excel(writer, sheet_name='그룹화')
API 응답을 Excel로
Python
import requests
import pandas as pd
# API에서 데이터 가져오기
response = requests.get('https://api.example.com/users')
data = response.json()
# DataFrame으로 변환
df = pd.DataFrame(data)
# Excel로 저장
df.to_excel('api_data.xlsx', index=False)
Node.js
const axios = require('axios');
const XLSX = require('xlsx');
async function apiToExcel() {
// API에서 데이터 가져오기
const response = await axios.get('https://api.example.com/users');
const data = response.data;
// Excel 생성
const ws = XLSX.utils.json_to_sheet(data);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "API Data");
XLSX.writeFile(wb, 'api_data.xlsx');
}
apiToExcel();
자동화
Python 스크립트
#!/usr/bin/env python3
import pandas as pd
import json
import sys
from pathlib import Path
def json_to_excel(json_file, excel_file=None):
"""JSON 파일을 Excel로 변환"""
# 출력 파일명 설정
if excel_file is None:
excel_file = Path(json_file).stem + '.xlsx'
try:
# JSON 읽기
with open(json_file, 'r', encoding='utf-8') as f:
data = json.load(f)
# 배열이 아니면 배열로 변환
if not isinstance(data, list):
data = [data]
# Excel로 변환
df = pd.DataFrame(data)
df.to_excel(excel_file, index=False)
print(f"성공: {json_file} → {excel_file}")
return True
except Exception as e:
print(f"오류: {e}")
return False
if __name__ == "__main__":
if len(sys.argv) < 2:
print("사용법: python json_to_excel.py input.json [output.xlsx]")
sys.exit(1)
json_file = sys.argv[1]
excel_file = sys.argv[2] if len(sys.argv) > 2 else None
json_to_excel(json_file, excel_file)
사용:
python json_to_excel.py data.json
python json_to_excel.py data.json output.xlsx
일괄 변환
import pandas as pd
import json
from pathlib import Path
def batch_convert(input_dir, output_dir):
"""디렉토리의 모든 JSON 파일 변환"""
input_path = Path(input_dir)
output_path = Path(output_dir)
output_path.mkdir(exist_ok=True)
for json_file in input_path.glob('*.json'):
try:
with open(json_file, 'r', encoding='utf-8') as f:
data = json.load(f)
if isinstance(data, list):
df = pd.DataFrame(data)
else:
df = pd.DataFrame([data])
excel_file = output_path / f"{json_file.stem}.xlsx"
df.to_excel(excel_file, index=False)
print(f"✓ {json_file.name} → {excel_file.name}")
except Exception as e:
print(f"✗ {json_file.name}: {e}")
# 사용
batch_convert('json_files', 'excel_files')
모범 사례
1. 데이터 검증
import pandas as pd
import json
def validate_and_convert(json_file, excel_file):
"""검증 후 변환"""
try:
with open(json_file, 'r', encoding='utf-8') as f:
data = json.load(f)
# 배열인지 확인
if not isinstance(data, list):
raise ValueError("JSON은 배열이어야 합니다")
# 빈 데이터 확인
if len(data) == 0:
raise ValueError("데이터가 비어 있습니다")
# 모든 항목이 딕셔너리인지 확인
if not all(isinstance(item, dict) for item in data):
raise ValueError("모든 항목은 객체여야 합니다")
# 변환
df = pd.DataFrame(data)
df.to_excel(excel_file, index=False)
return True
except Exception as e:
print(f"오류: {e}")
return False
2. 대용량 파일 처리
import pandas as pd
import json
def convert_large_json(json_file, excel_file, chunk_size=1000):
"""청크로 대용량 JSON 처리"""
with open(json_file, 'r', encoding='utf-8') as f:
data = json.load(f)
# 청크로 처리
with pd.ExcelWriter(excel_file, engine='openpyxl') as writer:
for i in range(0, len(data), chunk_size):
chunk = data[i:i + chunk_size]
df = pd.DataFrame(chunk)
# 첫 청크는 헤더 포함
header = i == 0
startrow = i if i > 0 else 0
df.to_excel(
writer,
sheet_name='Data',
index=False,
header=header,
startrow=startrow
)
print(f"처리됨: {i + len(chunk)} / {len(data)}")
3. 오류 처리
import pandas as pd
import json
from typing import Optional
def safe_convert(
json_file: str,
excel_file: str,
fallback: Optional[str] = None
) -> bool:
"""안전한 변환"""
try:
with open(json_file, 'r', encoding='utf-8') as f:
data = json.load(f)
df = pd.DataFrame(data if isinstance(data, list) else [data])
df.to_excel(excel_file, index=False)
return True
except FileNotFoundError:
print(f"파일을 찾을 수 없음: {json_file}")
except json.JSONDecodeError as e:
print(f"유효하지 않은 JSON: {e}")
except Exception as e:
print(f"변환 오류: {e}")
# 대체 파일이 있으면 사용
if fallback and Path(fallback).exists():
try:
with open(fallback, 'r') as f:
data = json.load(f)
df = pd.DataFrame(data)
df.to_excel(excel_file, index=False)
return True
except:
pass
return False
성능 비교
| 방법 | 1000행 | 10000행 | 100000행 |
|------|--------|---------|----------|
| pandas | 0.5s | 2s | 20s |
| openpyxl | 1s | 5s | 50s |
| xlsxwriter | 0.3s | 1.5s | 15s |
결론
JSON을 Excel로 변환하는 것은 온라인 도구나 프로그래밍 방법으로 간단합니다. 요구 사항에 따라 적절한 도구를 선택하세요.
빠른 권장사항:- 일회성 변환: 온라인 도구
- 자동화: Python pandas
- 웹 앱: JavaScript xlsx
- 대용량: 청크 처리
행복한 데이터 변환하세요!
관련 글
온라인 JSON 도구: 2026년 최고의 무료 도구 TOP 15
JSON 작업을 위한 최고의 온라인 도구를 발견하세요. 포맷터, 검증기, 에디터, 변환기 등 - 모든 무료 도구를 한 곳에서 비교합니다.
JavaScript와 JSON: 완벽한 가이드 2026
JavaScript에서 JSON을 마스터하세요. JSON.parse(), JSON.stringify(), 오류 처리, fetch API 및 모범 사례에 대한 완벽한 가이드입니다.
Python과 JSON: 완벽한 가이드 2026
Python에서 JSON을 마스터하세요. json 모듈, 파싱, 직렬화, 파일 작업 및 고급 기술에 대한 종합 가이드입니다.