구문
기본 규칙
Indentation공백만 사용 (탭 없음), 일관된 깊이
#주석 (줄 끝까지)
---문서 시작 마커
...문서 끝 마커
Case sensitive키와 값은 대소문자 구분
최소 예제
--- name: Alice age: 30 active: true
스칼라
스칼라 타입
hello문자열 (따옴표 없음)
"hello"문자열 (큰따옴표, 이스케이프 허용)
'hello'문자열 (작은따옴표, 리터럴)
42 / 3.14숫자 (정수 / 부동소수점)
true / false불리언
null / ~null 값
2026-03-26날짜 (ISO 8601)
따옴표 규칙
plain: no quotes needed special: "colon: and hash # need quotes" escape: "line\nnewline" literal: 'no \n escaping here'
시퀀스
블록 시퀀스
fruits: - apple - banana - cherry
플로우 시퀀스 (인라인)
colors: [red, green, blue] matrix: [[1, 2], [3, 4]]
객체의 시퀀스
users: - name: Alice role: admin - name: Bob role: user
매핑
블록 매핑
server: host: localhost port: 8080 debug: false
플로우 매핑 (인라인)
point: {x: 10, y: 20}
복합 키
? [first, second] : "compound key value"
앵커 및 앨리어스
정의 및 재사용
defaults: &defaults timeout: 30 retries: 3 production: <<: *defaults timeout: 60
참조
&name앵커 정의
*name앵커 참조 (앨리어스)
<<머지 키 — 현재에 매핑 병합
멀티라인 문자열
블록 스칼라
| (literal)줄바꿈을 그대로 보존
> (folded)줄바꿈을 공백으로 접음
|+ (keep)리터럴, 끝 줄바꿈 유지
|- (strip)리터럴, 끝 줄바꿈 제거
>- (fold+strip)접기, 끝 줄바꿈 제거
리터럴 블록
script: | echo "line one" echo "line two"
접기 블록
description: > This long text will be folded into a single line with spaces.
태그
타입 태그
!!str 42값을 문자열 "42"로 강제
!!int "42"값을 정수 42로 강제
!!float 1값을 부동소수점 1.0으로 강제
!!bool "true"값을 불리언으로 강제
!!null ""값을 null로 강제
!!binaryBase64 인코딩된 바이너리 데이터
태그 예제
port: !!str 8080 enabled: !!bool "yes" version: !!float 3
자주 쓰는 패턴
Docker Compose
services: web: image: nginx:alpine ports: ["80:80"] environment: NODE_ENV: production
GitHub Actions
on: [push, pull_request] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
yamllint구문 및 스타일 린팅
yq커맨드라인 YAML 프로세서 (jq와 유사)
Avoid NorwayNO는 불리언 false — 국가 코드는 따옴표로 묶기
Avoid !!python신뢰할 수 없는 YAML을 안전하지 않은 로더로 로드하지 말 것