Nanophotonics has emerged as a powerful tool for manipulating light on chips. Almost all of today's devices, however, have been designed using slow and ineffective brute-force search methods, leading in many cases to limited device performance. In this article, we provide a complete demonstration of our recently proposed inverse design technique, wherein the user specifies design constraints in the form of target fields rather than a dielectric constant profile, and in particular we use this method to demonstrate a new demultiplexing grating. The novel grating, which has not been developed using conventional techniques, accepts a vertical-incident Gaussian beam from a free-space and separates O-band (1300 nm) and C-band (1550 nm) light into separate waveguides. This inverse design concept is simple and extendable to a broad class of highly compact devices including frequency filters, mode converters, and spatial mode multiplexers.