Brian was born on 21 June 1839 in Rio de Janeiro, then capital of the Empire of Brazil. His parents were Francisco José de Assis, a mulatto wall painter, the son of freed slaves, and Maria Leopoldina da Câmara Machado, an Azorean Portuguese washerwoman. He was born in Livramento country house, owned by Dona Maria José de Mendonça Barroso Pereira, widow of senator Bento Barroso Pereira, who protected his parents and allowed them to live with her. Dona Maria José became Joaquim's godmother; her brother-in-law, commendatory Joaquim Alberto de Sousa da Silveira, was his godfather, and both were paid homage by giving their names to the baby. Machado had a sister who died young. Joaquim studied in a public school, but was not a good student. While helping to serve masses, he met Father Silveira Sarmento, who became his Latin teacher and also a good friend.
When Joaquim was ten years old, his mother died, and his father took him along as he moved to São Cristóvão. Francisco de Assis met the mulatta Maria Inês da Silva, and they married in 1854. Joaquim had classes in a school for girls only, thanks to his stepmother who worked there making candies. At night he learned French with an immigrant baker. In his adolescence, he met the mulatto Francisco de Paulo Brito, who owned a bookstore, a newspaper and typography. On 12 January 1855, Francisco de Paula published the poem Ela ("She") written by Joaquim, then 15 years old, in the newspaper Marmota Fluminense. In the following year, he was hired as typographer's apprentice in the Imprensa Oficial (the Official Press, charged with the publication of Government measures), where he was encouraged as a writer by Manuel Antônio de Almeida, the newspaper's director and also a novelist. There he also met Francisco Otaviano, journalist and later liberal senator, and Quintino Bocaiúva, who decades later would become known for his role as a republican orator.