This work reports a facile metal-organic-framework based approach to synthesize Sn/C composite, in which ultrasmall Sn nanodots with typical size of 2–3nm are uniformly embedded in the nitrogen-doped porous carbon matrix (denoted as Sn@NPC). The effect of thermal treatment and nitrogen doping are also explored. Owing to the delicate size control and confined volume change within carbon matrix, the Sn@NPC composite can exhibit reversible capacities of 575mAhg−1 (Sn contribution: 1091mAhg−1) after 500 cycles at 0.2Ag−1 and 507mAhg−1 (Sn contribution: 1077mAhg−1) after 1500 cycles at 1Ag−1. The excellent long-life electrochemical stability of the Sn@NPC anode has been mainly attributed to the uniform distribution of ultrasmall Sn nanodots and the highly-conductive and flexible N-doped carbon matrix, which can effectively facilitate lithium ion/electron diffusion, buffer the large volume change and improve the structure stability of the electrode during repetitive cycling with lithium ions.