The study of high contrast imaged brown dwarfs and exoplanets depends strongly on evolutionary models. To estimate the mass of a directly imaged substellar object, its extracted photometry or spectrum is used and adjusted with model spectra together with the estimated age of the system. These models still need to be properly tested and constrained. HD 4747B is a brown dwarf close to the H burning mass limit, orbiting a nearby, solar-type star and has been observed with the radial velocity method over almost two decades now. Its companion was also recently detected by direct imaging, allowing a complete study of this particular object. We aim to fully characterize HD 4747B by combining a well constrained dynamical mass and a study of its observed spectral features in order to test evolutionary models for substellar objects and characterize its atmosphere. We combine the radial velocity measurements of HIRES and CORALIE taken over two decades and high contrast imaging of several epochs from NACO, NIRC2 and SPHERE to obtain a dynamical mass. From the SPHERE data we obtain a low resolution spectrum of the companion from Y to H band, as well as two narrow band-width photometric measurements in the K band. A study of the primary star allows in addition to constrain the age of the system as well as its distance. Thanks to the new SPHERE epoch and NACO archival data combined with previous imaging data and high precision radial velocity measurements, we have been able to derive a well constrained orbit. We derive a dynamical mass of mB=70.0$pm$1.6 MJup which is higher than a previous study, but in better agreement with the models. By comparing the object with known brown dwarfs spectra, we derive a spectral type of L9 and an effective temperature of 1350$pm$50 K. With a retrieval analysis we constrain the oxygen and carbon abundances and compare them with the ones from the HR 8799 planets.