...
ECMWF makes available a GRIB decoding library (ecCodes) for the benefit of the WMO community. ecCodes can be freely downloaded from here and the documentation can be found here.
ecCodes provides a simplified access to GRIB2 headers through a set of virtual keys documented here.
S2S GRIB2 checking tool
...
(*) ecCodes version>= 2.13.0 is needed to see correct MARS meta data