The direct carbonisation of a carbon-rich organic salt, potassium phthalimide (PPI), generates porous carbons with porosity suitable for energy-related gas storage applications. The PPI-derived carbons exhibit high surface area of up to 2889 m(2) g(-1) and pore volume of up to 1.36 cm(3) g(-1), and the porosity can be readily tailored by choice of the carbonisation temperature and, to a lesser extent, carbonisation time. Depending on the preparation conditions, the PPI-derived carbons can be tailored to have ideal porosity for CO2 uptake at low pressure, which at 25 degrees C reaches 1.7 mmol g(-1) and 5.2 mmol g(-1) at 0.15 bar and 1 bar, respectively. The carbons also exhibit very impressive methane storage capacities of up to 18.2 mmol g(-1) at 25 degrees C and 100 bar. An important finding is that the carbons may be readily compacted to a high packing density of up to 1.10 g cm(-3) with retention of their textural properties. The consequence of the high packing density of the PPI-derived carbons, coupled with their high gravimetric methane uptake, is that they achieve exceptionally high volumetric uptake of up to 338 cm(3) (STP) cm(-3) at 25 degrees C and 100 bar, and volumetric working capacity (100-5 bar pressure swing) of 249 cm(3) (STP) cm(-3), which are significantly higher than most porous carbons and metal-organic frameworks (MOFs). PPI is thus a very attractive precursor for the simple synthesis of porous carbons with an unrivalled mix of properties for CO2 and methane storage applications.