There is no general way for that, but there is a way which works in most cases.
The reason why there is no general way for that is that the kernel doesn't know it either. To know it, it would first need to analyze the partition.
Without mounting the partition, the kernel knows only about its existence, but no more. Essentially, it is a line of blocks with random data. The kernel knows where it is and how to access it, but doesn't know what to do with it.
However, there are also user-space tools which can analyze the content of a filesystem without mounting it. As all filesystems have very different data structures, you need different tools to handle them.
In the case of ext2/3/4, it is
# dumpe2fs /dev/sdxN|grep '^Free blocks'
dumpe2fs 1.42.13 (17-May-2015)
Free blocks: 5721580
Or the (by far faster)
# tune2fs -l /dev/sdxN|grep '^Free blocks:'
Free blocks: 14227371