The pyrolysis mechanism of the ionic liquid [BMIm]N(CN)2 under microwave irradiation was discussed for the first time. The trimerization of the anion N(CN)-2 and the formation of a framework were firstly caused by the microwave irradiation. And then the carbonization of the framework occurred when the temperature reached 330 °C. The pyrolysis product was graphitic nitrogendoped carbon and mainly originated from the anion N(CN)-2. The nitrogen content and graphitization degree of the nitrogen-doped carbon was relied on the pyrolysis temperature.