中文
Home › Guides › sing-box configuration basics: the core parts of the JSON

sing-box configuration basics: the core parts of the JSON

A conceptual look at what inbounds, outbounds, route and dns do in a sing-box config, so you can read other people's configs.

ContentsThe skeleton of a configUnderstanding the data flowHow rules workDNS and routing work togetherAdvice for beginners
Fields change between versions. Before editing a config by hand, read the official docs for your version: https://sing-box.sagernet.org/

The skeleton of a config

A sing-box config is one JSON object. The most important top-level fields:

FieldRole
inboundsEntry points: where the program accepts traffic (local ports, a TUN adapter)
outboundsExits: where traffic finally goes (direct, proxy nodes, groups)
routeRouting: rules decide which exit a request uses
dnsDNS: which servers resolve names, and the resolution strategy
logLog level and output

Understanding the data flow

A request enters an inbound, the rules in route are matched in order, and the match points to an outbound. If nothing matches, the default exit is used.

How rules work

Rules can match on domain, domain suffix, IP range, process name, rule sets and more. Newer versions recommend referencing external rule lists through rule-set instead of the older geosite/geoip files.

DNS and routing work together

DNS resolution itself must go through routing, or resolution requests can take the wrong exit. A common approach is to assign different DNS servers to different domains. When this breaks, the symptom is usually "connected, but some sites will not load".

Advice for beginners

  1. You do not have to hand-write configs at first. Import a subscription in a graphical client.
  2. To learn, export the config the client generates and read it against the skeleton above.
  3. Back up before editing, and change one thing at a time.
  4. For errors caused by version differences, look up the migration notes for that version.

Apps mentioned

sing-box

Universal proxy platform: both a core and an official graphical client, configured mainly in JSON.

AndroidiPhone/iPadMacWindowsLinuxOpenWrtApple TV
ClientOpen sourceFreesing-boxUnverified
★ 40,260 · v1.14.4Details

Hiddify

Cross-platform client built on sing-box, aimed at working out of the box.

AndroidiPhone/iPadWindowsMacLinux
ClientOpen sourceFreesing-boxUnverified
★ 34,418 · v5.9.15Details

Karing

Flutter-based sing-box GUI that accepts many subscription formats and has a beginner mode.

iPhone/iPadAndroidMacWindowsLinuxApple TV
ClientOpen sourceFreesing-boxUnverified
★ 16,331 · v1.2.26.2934Details

GUI.for.SingBox

The same team’s graphical desktop client for sing-box.

WindowsMacLinux
ClientOpen sourceFreesing-boxUnverified
★ 8,235 · v1.29.0Details

Keep reading